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.mp3What parameters should I use for mp4 -> mp3?
43 Answers
The basic command is:
ffmpeg -i filename.mp4 filename.mp3or
ffmpeg -i video.mp4 -b:a 192K -vn music.mp3Check 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.mp3The q option can only be used with libmp3lame and corresponds to the LAME-V option. See Encoding VBR (Variable Bit Rate) mp3 audio:
I got it working from youtube mp4 videos with follwing command:
ffmpeg -i video.mp4 -vn audio.mp3 1