"Downloading youtube videos in linux" by
Talha
on Sunday, August 24, 2008
Let the posts begin. I've been busy over the past few months, and I'm going to be even busier. Life is good right now. I've realized that to keep this blog alive, I'll have to make time, instead of waiting until I'm free.I have a major post coming up, but for now heres a tiny one to keep the readers happy (btw, anyone reading this? If yes, please leave a comment).
Alot of people want to save the videos on youtube. This could be for many reasons, they may not have a 24/7 high speed broadband connection to load vids, they may want to save it for later or they may be afraid that it'll get removed. There are many tools out there that allow you to download these videos and they all work great (or not). However, you may not need to use them if you're one of the elites (like me) who run linux on their PC's!
Its really simple.
- Firstly, go to youtube and start viewing any video. You can leave it paused if you like. It doesn't really matter. What matters is that you let the whole video load (also called buffer) and that you do not navigate away from the page.
- Once the video has completely loaded (buffered), minimize your browser and open up your favorite terminal.
- In the terminal window, type : ls -lh /tmp/Flash*
- hit enter
- A file name should appear. Note that it begins with "Flash" and ends with random characters
- In the terminal window, type: cp /tmp/Flash* ~/my-video.flv
- hit enter. The file will now be saved in your home folder as "my-video.flv". You can use any name if you want.
- Now view the video with your favorite video player. I use vlc, but mplayer also works and I think xine does too (not sure though).
This guide is only for saving one video at a time. If you have loaded multiple movies, then multiple files will appear after you have performed Step 3. If you absolutely have to save multiple videos, wait for all the videos to load/buffer. Then use the following command:
cp /tmp/Flash* ~/
This will save all the files in your home folder, but with the original horrible naming scheme. You'll have to rename them yourself, and don't forget to add the extension "flv".
What if you have loaded/buffered multiple movies but only want to save one of them? There are two things you can do.
Method 1
The first method is to check the time of creation of the file. Once you have performed Step 3 above, the flash video files will be listed along with the date and time of creation. Match the time of creation with the time when you opened the video. The closest one is the one you want.
Method 2
The second method is to view all the files individually with a video player. Lets suppose I type the command in step 3 and the following list of files appears:
/tmp/FlashwHy8mG
/tmp/FlashpHy6XG
/tmp/FlashzPy8mG
/tmp/FlashoHyAmM
I use vlc to view videos, if you use a different video player then your command will be different.
Now to view the first video the command will be vlc /tmp/FlashwHy8mGB, for the second file I would use vlc /tmp/FlashpHy6XG. Using this, I can view the files and find out which one I want to save.
Regardless of which method you use, once you have found out which file you want to save, note down the name. Now lets assume that the file I want to save is the third file in the list above (/tmp/FlashzPy8mG), to save it I will have to use the command:
cp /tmp/FlashzPy8mG ~/my-video.flv
This will save the video in your home folder as my-video.flv. You can use a different name if you like. If you're new to linux, get used to the terminal, it's your best friend. Just don't practice in the root account.
Thats pretty much it.
If you need me to explain further, just leave a comment and I'll help you out.
Here's a final treat for you all. This can work on many of the video streaming sites for example metacafe, veoh, imeem etc.
There are some sites however where this little trick does not work. The only one thatI know of is expertvillage.com, but I'm sure there are more.