Extract audio from a video as MP3
Get the sound from a video (concert, lecture, interview) into an MP3 file. Choose the quality: the command keeps only the audio.
Updated on
How to use it
- Install ffmpeg if you haven't already.
- Open a terminal in the folder containing your file.
- Copy the generated command, adjust the file names if needed, then run it.
- Open the resulting file to check the result.
Choosing the quality
Variable mode (the -q:a option) adjusts the bitrate to the complexity of the sound and gives a smaller file than a constant bitrate at the same quality. Setting 2 (about 190 kbps) suits music, and 4 (about 165 kbps) suits voice and lectures. For plain speech, 128 kbps constant is enough.
Convert several files at once
On Linux or macOS, this loop extracts the audio from all the MP4 videos in the folder:
for f in *.mp4; do ffmpeg -i "$f" -vn -c:a libmp3lame -q:a 2 "${f%.mp4}.mp3"; doneFrequently asked questions
What is the -vn option for?
It tells ffmpeg to ignore the video track: only the audio is saved.
Can I extract the audio without any quality loss?
Yes, if the original audio is AAC: replace the "-c:a libmp3lame …" part with "-c:a copy" and give the output a .m4a name. No re-encoding takes place.
The video has several audio tracks. Which one is extracted?
ffmpeg picks a single track by default. To choose a specific one, add for example "-map 0:a:1" for the second.