Extracting audio from a YouTube video
January 7th 2008

This HowTo really has two parts:

1 - How to download a video from YouTube
2 - How to extract audio from any video

The second step is not limited to videos obtained in the first step, and the first step can obviously be made for the sake of it.

How to download a video from YouTube

When you play a video on YouTube, the contents of a FLV file are streamed to your screen. Downloading this FLV file is a bit more tricky than it should be, because there is no direct indication of the URL of this file in the code of the page of the video.

Apparently some guys got over it, and they made the software I use to do the job: a Firefox extension called DownloadHelper. Using it is so easy: a three-sphere icon appears to the right of the URL bar of Firefox. When a page contains material that can be downloaded with DownloadHelper (such as a YouTube video), the spheres in the icon are colorful and move (otherwise they are grayed-out, and still). You can then click on the icon to see a list of items to download, and choose the one you want (usually the .flv file).

How to extract audio from any video

It is so easy to do from the command line. First we use MPlayer to extract the audio in PCM/WAV format:

% mplayer filename.flv -vo null -ao pcm:fast:file=filename.wav

Then, we make use of oggenc to encode the WAV into Ogg Vorbis. For example, to encode with quality level 7 (a reasonable tradeoff between quality and size):

% oggenc filename.wav -q 7 -o filename.ogg

And that's all to it!

Tags: , , ,

2 Comments »

2 Responses to “Extracting audio from a YouTube video”

  1. Nishu on 10 Jan 2008 at 20:19 pm #

    well there are many simpler ways to get videos from you tube ..
    like using savetube or greasemonkey user script

  2. isilanes on 19 Feb 2008 at 12:19 pm #

    Easier than DownloadHelper? Let me doubt it.

    The methods you mention could have an edge if they allowed for stripping audio from the video directly. However, I would still prefer the flexibility and control of my two step procedure: I use the browser to find a video I like, then with a simple click I download it, and then I have two lines of code (that I can alias or script) that do precisely what I want with it.

Trackback URI | Comments RSS

Leave a Reply

Subscribe without commenting

« | »

  • The contents of this blog are under a Creative Commons License.

    Creative Commons License

  • Meta