All posts

MP3 to AAC via CLI

Encode MP3 to AAC with ffmpeg.

Open online converter

Packages to install

Only ffmpeg is required. The built-in aac encoder writes ADTS AAC at a constant bitrate.

ffmpeg
apt install
sudo apt-get update
sudo apt-get install -y ffmpeg

How to run the command

ffmpeg -i input.mp3 -vn -c:a aac -b:a 192k output.aac. -vn drops album art so the result is audio-only.

ffmpeg
ffmpeg -y -i input.mp3 -vn -c:a aac -b:a 192k output.aac

Dockerfile example

Build a minimal Ubuntu image with the required packages and run the conversion inside the container.

Dockerfile
FROM ubuntu:24.04

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ffmpeg && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /work
docker build && docker run
docker build -t mp3-to-aac .
docker run --rm -v "$PWD:/work" -w /work mp3-to-aac \
  ffmpeg -y -i input.mp3 -vn -c:a aac -b:a 192k output.aac

Example commands

Run these locally after installing the packages, or inside the container from the Dockerfile.

Example 1
ffmpeg -y -i input.mp3 -vn -c:a aac -b:a 192k output.aac
Example 2
ffmpeg -y -i track.mp3 -vn -c:a aac -b:a 192k -ar 44100 -ac 2 track.aac