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?

  • 2
    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 '14 at 18:03
  • @ThomWiggers is it necessarily lossy? I don't know how mp4s are encoded, but as long as you can separate video and audio, it shouldn't have to be – Nathan Jun 17 '19 at 14:47
  • The original version of this question was not clear how the audio was encoded – that got changed in edits. Remuxing does not have to be lossy. – Thom Wiggers Jun 18 '19 at 15:03

The basic command is:

ffmpeg -i filename.mp4 filename.mp3


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.


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:

  • @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
  • This one finally played also the Android Music player. Thanks – michalzuber Nov 10 '15 at 7:24
  • 1
    And to convert whole directory (including filenames with spaces) with the above command: for i in *.mp4; do ffmpeg -i "$i" -q:a 0 -map a "$(basename "${i/.mp4}").mp3"; done; – kingSlayer Nov 29 '16 at 19:27
  • How is the resulting .mp3 different from the vanilla command ffmpeg -i vid.mp4 audio.mp3 in @Naga Harish M 's answer? Less lossy? – Nathan Jun 17 '19 at 14:48