What is the easiest way to extract an audio track from a video file and save it as an MP3 file?
You can do this in VLC.
Once you have started VLC:
- select "Media" --> "Convert/Save"
- Click "Add..." and select the file you want
- Click "Convert / Save" (on the bottom)
- Provide a "Destination file:"
- Select the "Profile" (i.e. "Audio - MP3", "Audio - Vorbis (OGG)", etc.)
- Click "Start"
- Relax and enjoy your shoes
You can install VLC from Synaptic or the Software Center.
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
avconv (from the command line, no need to install ffmpeg as avconv is its port to ubuntu)
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.
- 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.
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
$ 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
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.