All posts
Extract audio from video via CLI
ffmpeg: drop the video track and encode MP3, WAV, or AAC.
Open online converterPackages to install
Only ffmpeg is required. libmp3lame writes MP3, pcm_s16le writes WAV, and aac writes ADTS AAC.
ffmpeg
sudo apt-get update
sudo apt-get install -y ffmpegHow to run the command
Use -vn to skip video and -map 0:a:0 for the first audio stream. Then pick a codec: libmp3lame, pcm_s16le, or aac.
ffmpeg -y -i input.mp4 -vn -map 0:a:0 -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 video-to-audio .
docker run --rm -v "$PWD:/work" -w /work video-to-audio \
ffmpeg -y -i input.mp4 -vn -map 0:a:0 -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.mp4 -vn -map 0:a:0 -c:a libmp3lame -b:a 192k output.mp3ffmpeg -y -i input.mp4 -vn -map 0:a:0 -c:a pcm_s16le output.wavffmpeg -y -i input.mp4 -vn -map 0:a:0 -c:a aac -b:a 192k output.aac