All posts
Audio to MP3 via CLI
Encode any audio to MP3 with ffmpeg and libmp3lame.
Open online converterPackages to install
Only ffmpeg is required. libmp3lame encodes MP3 at a constant bitrate.
ffmpeg
sudo apt-get update
sudo apt-get install -y ffmpegHow to run the command
ffmpeg -i input.wav -vn -c:a libmp3lame -b:a 192k output.mp3. The same profile works for M4A, AAC, FLAC, and OGG.
ffmpeg -y -i input.wav -vn -c:a libmp3lame -b:a 192k output.mp3Dockerfile example
Build a minimal Ubuntu image with the required packages and run the conversion inside the container.
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 -t audio-to-mp3 .
docker run --rm -v "$PWD:/work" -w /work audio-to-mp3 \
ffmpeg -y -i input.wav -vn -c:a libmp3lame -b:a 192k output.mp3Example commands
Run these locally after installing the packages, or inside the container from the Dockerfile.
ffmpeg -y -i input.wav -vn -c:a libmp3lame -b:a 192k output.mp3ffmpeg -y -i input.m4a -vn -c:a libmp3lame -b:a 192k output.mp3ffmpeg -y -i input.flac -vn -c:a libmp3lame -b:a 192k output.mp3