What is the easiest way to extract an audio track from a video file and save it as an MP3 file?


8 Answers 8


Very simple CLI solution:

ffmpeg -i VIDEOFILE -acodec libmp3lame -metadata TITLE="Name of Song" OUTPUTFILE.mp3

In case you don't have ffmpeg installed:

sudo apt-get install ffmpeg
  • 1
    I needed to list codecs before, with ffmpeg -codecs, to know availability
    – CapelliC
    Jun 3, 2013 at 17:30
  • 2
    In case ffmpeg says Unknown encoder 'libmp3lame', try to sudo apt-get install libavcodec-extra-53
    – NIA
    Aug 12, 2013 at 12:10
  • 1
    Package ffmpeg is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'ffmpeg' has no installation candidate
    – MERose
    Oct 18, 2015 at 13:21
  • 1
    @MERose change ffmpeg to avconv. It is a fork of ffmpeg, and is compatible with ffmpeg options (at least the ones in the answer).
    – Hi-Angel
    Mar 19, 2016 at 9:56
  • you can also get a piece of it. -ss 00:00:03 -t 00:00:08 will give you 7 seconds from the 2nd. I use this to produce my custom ringtones :)
    – Augusto
    Jul 8, 2019 at 13:35

You can do this in VLC.

Once you have started VLC:

  1. select "Media" --> "Convert/Save"
  2. Click "Add..." and select the file you want
  3. Click "Convert / Save" (on the bottom)
  4. Provide a "Destination file:"
  5. Select the "Profile" (i.e. "Audio - MP3", "Audio - Vorbis (OGG)", etc.)
  6. Click "Start"
  7. Relax and enjoy your shoes

You can install VLC from Synaptic or the Software Center.

  • 1
    HowToGeek reported [their vlc ripping method] as rending poor quality audio. Jan 18, 2015 at 20:27
  • Very easy to use, and the sound quality is very good. Jan 27, 2020 at 15:15

avidemux can do this.

It is inside Ubuntu Software Center or you can install it from the command line with:

sudo apt-get install avidemux

Using avconv (from the command line, no need to install ffmpeg as avconv is its port to ubuntu)

  1. use avconv -i "input file name" to discover the file (video and audio mappings). In the example shown below, the audio that I wanted to strip had 0:0 "index". (If you read thoroughly the output from avconv -i ... command you will get this.
  2. Then issue the command avconv -i "input file name" -map 0:0 -c:a copy -metadata TITLE="title name" -metadata AUTHOR="author name" "output file name"

Test it with several output file formats and see.

  • probably the fastest (didn't time it though). +1 for the '-c:a copy'. to note: make sure the output is in the same format as the encoding in the video, or you'd need to specify codec in space of 'copy' Dec 16, 2014 at 11:41

The best way would be to use a tool that just handles the container. For MP4 I would recommend the MP4Box tool from the gpac package. For other containers like Matroska there are projects and tools like MKVToolNix.

Retrieve information about the file (Note: You could also do this with mediainfo):

$ MP4Box -info 29c3-5400-en-hacking_cisco_phones_h264.mp4 
* Movie Info *
    Timescale 1000 - Duration 00:54:30.144
    Fragmented File no - 2 track(s)
    File Brand isom - version 512
    Created: UNKNOWN DATE
File has no MPEG4 IOD/OD

iTunes Info:
    Name: Hacking Cisco Phones
    Artist: Ang Cui, Michael Costello
    Album: Chaos Communication Congress 2012 (29C3)
    Comment: http://events.ccc.de/congress/2012/Fahrplan/events/5400.en.html
    Genre: lecture
    Encoder Software: Lavf54.29.104

Track # 1 Info - TrackID 1 - TimeScale 25 - Duration 00:54:30.080
Media Info: Language "Undetermined" - Type "vide:avc1" - 81752 samples
Visual Track layout: x=0 y=0 width=1024 height=576
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 720 x 576
    AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 3
    NAL Unit length bits: 32
    Pixel Aspect Ratio 64:45 - Indicated track size 1024 x 576

Track # 2 Info - TrackID 2 - TimeScale 48000 - Duration 00:54:30.143
Media Info: Language "English" - Type "soun:mp4a" - 153285 samples
MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
MPEG-4 Audio MPEG-4 Audio AAC LC - 2 Channel(s) - SampleRate 48000
Synchronized on stream 1
Alternate Group ID 1

Extracting individual tracks to raw format:

$ MP4Box -raw 1 29c3-5400-en-hacking_cisco_phones_h264.mp4 
Extracting MPEG-4 AVC-H264 stream to h264
$ MP4Box -raw 2 29c3-5400-en-hacking_cisco_phones_h264.mp4 
Extracting MPEG-4 AAC

Show original file and results:

$ ls -1 29c3-5400-en-hacking_cisco_phones_h264*

Which video format do you want to convert from? I use audacity to extract audio from mp4 and flv videos (haven't tried other formats but I assume it'll work just the same). When you open up the file, the video part is ignored, instead you'll have only the audio to work on (like normalize or truncate silence) and then export it to any formats including mp3.


This can be easily done with avidemux (sudo apt-get install avidemux to install it).

Open the video file with avidemux, then choose a codec for the Audio in the combobox, then go to "Audio" menu and you'll find a "Save..." option.


Download mkvmerge GUI from the Ubuntu Software Center:

  1. Add the video file and unselect the video part
  2. click "Start Muxing"
  3. The audio file will be save in the same directory were the video file is located.

Not the answer you're looking for? Browse other questions tagged or ask your own question.