How can I convert MP4 video to MP3 audio with FFmpeg?
I need to extract an MP3 audio track from an MP4 video with ffmpeg. I can do this for .flv -> mp3, but I don't know the command line parameters for mp4->mp3. For example, flv -> mp3:
ffmpeg -i video.flv -acodec copy audio.mp3
What parameters should I use for mp4 -> mp3?
The basic command is:
ffmpeg -i filename.mp4 filename.mp3
or
ffmpeg -i video.mp4 -b:a 192K -vn music.mp3
Check this URL: MP4 Video to MP3 File Using ffmpeg (Ubuntu 9.10 Karmic Koala) link broken [Updated on 7th Dec 2021]
Note: Ubuntu does not supply FFmpeg, but the fork named Libav. The syntax is the same – just use avconv
instead of ffmpeg
for the above examples.
The better way to encode MP3 is to use -q:a
for variable bit rate.
ffmpeg -i in.mp4 -q:a 0 -map a out.mp3
The q
option can only be used with libmp3lame and corresponds to the LAME
-V
option. See Encoding VBR (Variable Bit Rate) mp3 audio:
https://trac.ffmpeg.org/wiki/Encode/MP3
I got it working from youtube mp4 videos with follwing command:
ffmpeg -i video.mp4 -vn audio.mp3