Saturday, February 23, 2008

Downloading and ripping music from YouTube videos

Uses


  • music videos

  • speeches

  • news stories

  • video podcasts

  • etc.

Ways to download YouTube videos

  • On Debian-based systems,

    sudo apt-get install youtube-dl; youtube-dl http://youtube.com/watch?v=foobar123

    The best reason to use youtube-dl is so that you can automate this process to do batch downloads.

  • Use a web-based tool

  • The easiest way is to let your browser do it for you. Go to the video page, and wait until your browser downloads it. Then check /tmp on *nix systems with Firefox (not sure about other browsers) for a file like FlashXXXXX where X is an alphanumeric character. This is the downloaded FLV video.

  • Another solution for anyone using Firefox is to look in the disk cache (about:cache?device=disk) and look for an entry starting with http://www.youtube.com/get_video?video_id=foobar123&t=foobar456. Clicking on this entry will show you its location on disk e.g. /home/yourusername/.mozilla/firefox/xx4xmys7.default/Cache/FB999693d01. The main benefit of using this method is that Firefox will show you the direct URL of the video on the web: http://lax-v305.lax.youtube.com/get_video?video_id=BUNCHOFTEXTHERE

  • Look through the site html and javascript and figure out the flv URL. jk :)


Ways to extract the audio from the file

  • Use vixy.net. Just type in the youtube URL and select mp3 from the dropdown.

  • Use ffmpeg -i youtubevid.flv youtubemusic.mp3

  • Use mplayer -dumpaudio youtubevid.flv -dumpfile youtubemusic.mp3



Vixy.net method [via labnol.blogspot.com]

FFmpeg method [via linux.byexamples.com]

mplayer method [via tips.webdesign10.com] (also created a bash script to automate this)

No comments: