Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Sep 6 '11 at 6:06

This question came from our site for professional and enthusiast programmers.

    
If you don't really need an MP3, I would not convert the audio: MP4->MP3 is a lossy transformation, you will lose extra source information. –  Thom Wiggers Dec 8 '13 at 0:33
    
no more ffmpeg for ubuntu 14.04 –  Louis Oct 7 at 18:03

2 Answers 2

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)

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.

share|improve this answer
    
Thank you! This quality is best, or I can do better? –  user916350 Sep 6 '11 at 5:32
    
try with 320kbs en.wikipedia.org/wiki/MP3#Bit_rate –  Naga Harish Movva Sep 6 '11 at 5:36
    
no more ffmpeg for ubuntu 14.04 –  Louis Oct 7 at 18:03
    
@Louis You can still download it from ffmpeg.org/download.html –  slhck Nov 22 at 7:39

The better way to encode MP3 is to use -q:a for variable bit rate.

ffmpeg -i k.mp4 -q:a 0 -map a k.mp3

The q option can only be used with libmp3lame and corresponds to the LAME -V option. See:

share|improve this answer
    
@slhck ...that's a good point, but I've just tested on a video file, and leaving out -vn just copies the audio stream. I suppose ffmpeg must have some way of detecting the difference (I just checked a file with ffprobe, and the video was stream 1 rather than the usual 0, and had some metadata: comment : Cover (front)) –  evilsoup Feb 17 '13 at 21:31

protected by Community Aug 12 at 11:12

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?