Downloading, converting and importing Youtube videos into iTunes *UPDATED*
I don't know how useful it really is, but I have a little method of grabbing videos from sites like Youtube, or any page with an embedded video, converting it to a Quicktime format and importing it into iTunes. This, of course, makes it so ultimatly I could copy it to an iPod for portable viewing.
This involves some command line work and downloading a few things but if you stay cool and take it step by step it's a snap to pull off. We're going to use all of the following tools: Firefox 3.x, Video DownloadHelper (Firefox add-on) and Mplayer (with Mencoder). Most people are using Firefox already but if you aren't please download it, install it, and use it as your primary web browser. Here are links to the downloads you'll need:
Mozilla, Firefox
Video DownloadHelper
Mplayer (and mencoder) (download MPlayer 1.0rc2 Windows if you are using Windows)
Mplayer is the only mysterious tool here and most of this post has to do with installing and setting it up within Windows. If you are using Linux you can install Mplayer from the repositories (in Ubuntu just bust a sudo apt-get install mplayer mencoder or open the package manager and search for them). Mplayer is an open source media player that can play almost anything from DVDs to AVI, Flash or Quicktime videos. Mplayer comes with another program called Mencoder which is a VERY handy command line tool for encoding videos. You can convert video files to a large number of different formats. It is with this tool that we can convert the Flash videos from Youtube to Quicktime format for importing into iTunes.
Under Windows, installing Mplayer is a little old-school. Instead of an install application like we are all used to these days this one comes as a complete program that just needs to be copied to a folder somewhere and run from there. I like to put applications like that under my home folder so I'll recommend doing it MY way just to make this easier on me. Open a file explorer and navigate to "C:\Users\Your Account", for Vista, or "C:\Documents and Settings\Your Account" for XP. In that folder create a new folder called opt and extract the zip file you downloaded for Mplayer to that folder (creating a subfolder that contains the mplayer files). You'll see in the Mplayer folder that there are both mplayer.exe and mencoder.exe along with a few folders and other files.
The next step is to add this new folder to your Windows path variable allowing you to use the mplayer.exe and mencoder.exe files at the command prompt from any folder (trust me this is a major typing shortcut). So if the path to your Mplayer files and folders is "C:\Users\Your Account\opt\mplayer" then that is what you'll need to have handy in this step. Open up a command prompt by holding down the Windows Key (two to the left of your spacebar) and tapping R. This brings up the Run dialog. Type in cmd and press Enter. Paste the following code to the prompt and press Enter (paste by right-clicking the window's title bar, select Edit, select Paste)
RUNDLL32.EXE shell32.dll,Control_RunDLL sysdm.cpl
This launches the System properties dialog. Go to the Advanced tab and find the Environment Variables button and click it. You'll see 2 Variable/Value lists. If you don't see a 'PATH' variable in the top list, click New and add a variable called PATH. For the value add in the path to Mplayer. Put it in quotes if there are any spaces in the path. If there already is a PATH variable then just select it and click Edit. Add a semi-colon to the end of the existing value and then add your new path to the end. Save the changes (click OK) and exit this dialog by clicking OK. Close out the System properties dialog as well, we're done there. Close the command prompt window and then open a new one to reload the system variables. Now try typing the following at the prompt:
mplayer
You should see something like the following:
MPlayer 1.0rc2-4.2.1 (C) 2000-2007 MPlayer Team CPU: Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz (Family: 6, Model: 15, Stepping: 11) CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1 Compiled with runtime CPU detection. Usage: mplayer [options] [url|path/]filename Basic options: (complete list in the man page) -voselect video output driver ('-vo help' for a list) -ao select audio output driver ('-ao help' for a list) vcd:// play (S)VCD (Super Video CD) track (raw device, no mount) dvd:// play DVD title from device instead of plain file -alang/-slang select DVD audio/subtitle language (by 2-char country code) -ss seek to given (seconds or hh:mm:ss) position -nosound do not play sound -fs fullscreen playback (or -vm, -zoom, details in the man page) -x -y set display resolution (for use with -vm or -zoom) -sub specify subtitle file to use (also see -subfps, -subdelay) -playlist specify playlist file -vid x -aid y select video (x) and audio (y) stream to play -fps x -srate y change video (x fps) and audio (y Hz) rate -pp enable postprocessing filter (details in the man page) -framedrop enable frame dropping (for slow machines) Basic keys: (complete list in the man page, also check input.conf) <- or -> seek backward/forward 10 seconds down or up seek backward/forward 1 minute pgdown or pgup seek backward/forward 10 minutes < or > step backward/forward in playlist p or SPACE pause movie (press any key to continue) q or ESC stop playing and quit program + or - adjust audio delay by +/- 0.1 second o cycle OSD mode: none / seekbar / seekbar + timer * or / increase or decrease PCM volume x or z adjust subtitle delay by +/- 0.1 second r or t adjust subtitle position up/down, also see -vf expand * * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *
If not then the your PATH variable isn't working. Try following the instructions again or searching out a better tutorial on how to do that if mine was confusing.
If it worked then you're ready to get down to business. If you haven't installed Firefox and Video DownloadHelper then do that and let's go to Youtube to grab a video. Video DownloadHelper adds a button to the top of Firefox that's site context sensitive. If there's nothing on the current page for it to download it appears grayed out but if there IS then it becomes animated and the circles are red, blue and yellow. If you click it you'll get a dialog that SUCKS to navigate but if you click the tiny arrow to the right of the animated circles you'll see a list of what you can download. The entry at the bottom of the list is always the most recent file you have viewed (if you're jumping around a lot) or the video you are currently viewing. Navigate to a Youtube video you want to download, wait for the circles to animate, click the tiny arrow and you should see something with a .flv extension at the bottom of the list (or possibly the only thing in the list) - that's your video. Click on that and save it to your DESKTOP. Usually it will appear that the download is hanging (not going). The reason is that the file is still downloading to your browser. You can either wait for that to finish or navigate away from the page that video is on. Video DownloadHelper can queue multiple video downloads so you can stack 'em up and they will all eventually download.
Once this file is on your desktop, verify that it is, have a command prompt ready. If you just opened your command prompt you're current directory will be your user folder. Change directory to your Desktop (from the user folder type cd Desktop). You can play the file using Mplayer to make sure it's the one you wanted. Type dir and Enter to see the list of files on your desktop. Then type
mplayer filename.flv
where 'filename.flv' is your video file. Note that you can use Window's handy TAB shortcut here. Type the first few letters of the file and then hit TAB and Windows will complete the filename for you. If you keep hitting tab it will cycle through all the files in the current folder. The player should launch and you'll see your video playing. Type Q to close it.
Now we'll convert the FLV file to a MOV, Quicktime, file with mencoder. This is done in a single command:
mencoder filename.flv -o output-filename.mov -ovc lavc -lavcopts vglobal=1 -oac mp3lame -of lavf -lavfopts format=mov
where 'filename.flv' is your downloaded file and 'output-filename.mov' is the made-up filename for the output file. The rest of it is all mencoder magic. Type (or copy, paste and edit) this code into your command prompt. Make sure the filenames are correct and all other options are typed correctly and press Enter. You should see it working away (it might look crazy like it's creating 100's of lines of errors). It should finish normally and you'll then have your MOV file on your desktop. If you have Quicktime installed you can double-click the file and it should play in Quicktime's player no problem.
The last step is to simply drag the file from your desktop into the iTunes window and it should add into your Movies list.
You're done!
You can also use that mencoder code above to convert nearly any other format video to MOV including AVI, MPG, and WMV videos making it easy for you to add basically any video to iTunes and to your iPod or iPhone. This is handy if you've got videos from your camera or from some other source that you'd like to put into iTunes and onto your portable "i" device. Mencoder can also convert video files into MPG format or AVI format for easy cross-platform compatibility. I'll hit that up in another post....sometime....
UPDATE
This technique does not make it so the videos can be copied to your "i" device. I think I need to use a different encoding or something. When I have it figured out I'll post it up here. For now, at least, you can copy your videos to iTunes and maybe get started tinkering with Mencoder yourself.
