Extract Audio From Youtube HD MP4 Video Files

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

libav-logo-textWhat if you want to get the audio file corresponding to one of the HD videos that you like on Youtube? It is very easy if you have a linux box to run a few simple commands. This post would also tell you how to convert an aac or m4a file to mp3.

First step is of course download the mp4 file corresponding to the HD video from youtube. This is described in an earlier post here. This step can be easily achieved by using a simple Firefox plugin called DownloadHelper.

Now that you have downloaded the Hi-def video file.We would go about conversion using avconv which is now the preferred Audio/Video converter replacing now deprecated ffmpeg. You may need to install it on Ubuntu using following command:

sudo apt-get install avcodec

Check the audio codec from command line using the following command:

avconv -i file_name.mp4

This would spit out data like this:

avconv version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
built on Apr  2 2013 17:02:36 with gcc 4.6.3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘Main_Tenu_Sam.mp4’:
major_brand     : mp42
minor_version   : 0
compatible_brands: isommp42
creation_time   : 2013-04-18 07:53:24
Duration: 00:05:49.55, start: 0.000000, bitrate: 2094 kb/s
Stream #0.0(und): Video: h264 (High), yuv420p, 1280×720, 1900 kb/s, 30 fps, 30 tbr, 60 tbn, 60 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 192 kb/s
creation_time   : 2013-04-18 07:53:28
At least one output file must be specified

Of course there would be better ways of doing this, but this does the job. Text highlighted in blue is of our interest. It is most likely that the HD video file would have audio in aac format. If that is the case then run the following command to get the audio extracted:

avconv -i INPUT_FILE.mp4 -map 0:1 -c:a copy OUTPUT_FILE.m4a

Now if you are not happy with m4a format and want an mp3 as well. I would recommend you to use pacpl (Perl Audio Converter, sudo apt-get install pacpl) and run following command to convert the m4a file(s) to mp3

pacpl --eopts="--vbr-new -V 2" --to mp3 *m4a

You might also like

Extract Audio Out of Youtube (flv) Videos for Free Earlier I talked...
Download and Convert YouTube Videos For Free Video DownloadHelper...
Notion Ink Interview at CES 2011 via Crunchgear CrunchGear...
Watch Google IO 2011 Live!!!   Excited...

About the Author

has written 346 posts on this blog.

Meditating towards his "nerdvana", lifehacker is a teacher by the day and a nerdy blogger by the night. He lives to learn and yearns to learn living.

One Comment on “Extract Audio From Youtube HD MP4 Video Files”

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!


Copyright © 2020 Hack Your Life!. All rights reserved.
Proudly powered by WordPress. Developed by Deluxe Themes