Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

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

share|improve this question

marked as duplicate by Lucio, karel, i08in, Amith KK, LnxSlck Feb 19 at 11:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

8 Answers 8

up vote 6 down vote accepted

avidemux (tutorial) can do this.

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

sudo apt-get install avidemux

share|improve this answer

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
share|improve this answer
1  
I needed to list codecs before, with ffmpeg -codecs, to know availability –  CapelliC Jun 3 '13 at 17:30
2  
In case ffmpeg says Unknown encoder 'libmp3lame', try to sudo apt-get install libavcodec-extra-53 –  NIA Aug 12 '13 at 12:10

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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

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

share|improve this answer

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
Self-synchronized

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*
29c3-5400-en-hacking_cisco_phones_h264.mp4
29c3-5400-en-hacking_cisco_phones_h264_track1.h264
29c3-5400-en-hacking_cisco_phones_h264_track2.aac
share|improve this answer

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.
share|improve this answer

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