How to download & save streaming video from the internet, using Linux

30/03/2009

IMPORTANT: I HAVE UPDATED DOWNLOADING INFO. CHECK THIS LINK. BUT THIS POST IS STILL USEFUL.

The information in this post will help you download and save video files that are hosted on sites like Youtube, Supernovatube, Youku, Megavideo, and linked to by sites like SurfTheChannel.com, free-tv-video-online.info and watch-movies-links.net. It is a good idea to read the entire post before using any of these methods, as host sites have changed from time to time, and so have the methods you can use to download the streaming video files.

Seen the latest cool video on Youtube?  Want to save it on your hard drive so you can watch it again at your leisure or share it with your internetless friends?  Well, it’s simple – if you use Linux.  Everything I explain in this post was done on a computer running Ubuntu 8.10, but I think it will work with any distro.

Okay, let’s start with Youtube videos.  First, watch the video.  Then, before you navigate away from that web page, go and look in your system’s /tmp directory.  You should find a flash video file, named something like Flashbt0cVD.  That’s the file you want.  So move it to your home directory (or wherever you keep your videos) and rename it something more descriptive.

This trick will also work with the movie and TV videos  files streaming over the internet via sites like www.surfthechannel.com, www.free-tv-video-online.info, tv-video.net and www.watch-movies-links.net.

There is a problem.  One or two of the video links sites (like tv-video.net) delete temporary files when they have finished playing.  This means you can’t move the file out of /tmp after you’ve watched it.  The solution is to link the temporary file to one in your home directory before the temporary file is deleted.  So you start to play the video, then go look in the /tmp directory. You’ll find a randomly-named video file there.  You need to link it to your home directory.  Do this by running this command in terminal:

ln /tmp/Flashuh4G6s ~/video.flv

Now you have got the video file in your /home.  You have to make sure that the name you give to the new linked file does not already exist in the directory.  So in the example above, you would first check that there is no file called video.flv in your home directory.

But there’s another problem.  If you watch a video via the links sites that is hosted at Youku, the video will be delivered as a series of small files (12-13 MB each).  But this isn’t a serious problem.  When they’ve downloaded you can put the randomly-named files into the correct viewing order by checking the properties of the files, looking at the time when the files were created.

If you have any queries, feel free to leave Comments.

UPDATE: If you are a Windoze user and you want to learn how to save streamed media, you should check out this site. There you’ll find info on how to capture and save video from lots of websites, plus audio files from last.fm and other internet radio stations. I only use Linux, so I can’t verify the accuracy of the info. But it looks good.

UPDATE 2:
Here’s info about a couple more tools for downloading video from the web. One for grabbing BBC TV (and radio) content, and one for those Youtube videos we all know and love.

For some time now, users of any operating system have been able to watch BBC TV shows streamed over the internet by BBC iPlayer. But if you wanted to download programmes, you used Windows or you were shit out of luck.

Now, Linux users can download BBC content via the new iPlayer Desktop application. But I don’t like it. The content is crawling with DRM. And the player doesn’t work properly on my EEE PC. It might work okay on a better-specified computer. But iPlayer Desktop is compatible with just Intrepid and Jaunty and my desktop machine runs Hardy (I’m talking Ubuntu here – the app works on other distros too). Anyway, I don’t like the app so I’m not supplying a link to it. It’s my blog so blah! If you really want to try it for yourself, check out the “Labs” link on the iPlayer web page.

Anyway, if you want to download BBC TV and radio shows and you use Linux, there is an easy solution – get_iplayer.
This is how it works: Steve Jobs was desperate to sell his crappy iPhones in the UK. So he turned on his diabolical charm and convinced the BBC to offer iPlayer downloads to iPhones. This happened many moons ago, when only Windows OSes could download the content. But some dastardly fellow created a program that pretended to be an iPhone. Oh, and get this: the DRM that infects all the content downloaded from iPlayer is absent from the .mov files sent to iPhones and consequently computers running get_iplayer. It’s a command-line utility, which might put some people off. But as far as I’m concerned there isn’t much wrong with command-line utilities in Linux. So check it out!

The other video download solution I want to present here is the excellent pwnyoutube.com. The way this site works is simple. When you search for or go to watch a video on Youtube, you get an URL something like:
http://www.youtube.com/watch?v=ufzqypO2k_A
To download this video, you type that URL into your browser’s address bar, then add the letters “pwn” like this:
http://www.pwnyoutube.com/watch?v=ufzqypO2k_A
Go to that URL and you will find download links for the video in question. You can download the file in .flv flash format, and most are also available in mp4.

If you have an unreliable internet connection, you can marry pwnyoutube with wget to great effect. Let’s say you want a video of The Clash playing London Calling live. A search of Youtube may turn up this video URL:
http://www.youtube.com/watch?v=Idwibw0-lb4
So, you run the edited URL in your browser:
http://www.pwnyoutube.com/watch?v=Idwibw0-lb4
This brings you to a web page offering 2 download links. You want the “high quality” mp4 version. But your network connection is lousy. If you set the browser to download this file, chances are the connection will drop before the download completes. But this is no problem. Just right-click on the download link and select “Copy Link Location”. Now open a terminal and paste the download url into the following command:
wget -c http://deturl.com/save-video.mp4?http%3A%2F%2Fv18.lscache5.c.youtube.com%2Fvideoplayback%3Fip%3D0.0.0.0%26sparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Cburst%252Cfactor%26itag%3D18%26ipbits%3D0%26signature%3D7ABACC132F8C18AAF6A0649B1669DB89EDFF0B83.AB3039808ECB20B7124585313CB75A55C2C7E4A1%26sver%3D3%26expire%3D1250665200%26key%3Dyt1%26factor%3D1.25%26burst%3D40%26id%3D21dc226f0d3e95be
Wget will download the file, and the -c flag means that if the connection is broken, you can run the same command when the link is resumed and wget will start the download where it left off.

Hope this helps.

UPDATE OF THE UPDATE: OMG they have ruined PWNYoutube!!! 😦

Back when I first wrote the review of PWNYoutube, it was simple, and great in its simplicity: you found the video’s URL, you added “pwn” to the URL, browsed to that URL… and you were given a couple of download links. I liked to right-click the link, copy it, then paste it into a wget command in the terminal. Brilliant, right?

But now, you do all that adding “pwn” to the URL stuff… but when you go to that URL, instead of getting a couple of simple download links, you are confronted with a bunch of complicated ridiculousness. “Use one of: SaveVid | YouDDL | ClipNabber | KeepVid…” etc etc etc. No simple download link. No simple wget. Just a bunch of downloading utilities/services/whatevers that I know nothing about, and which I want to know nothing about. Ruined, man. Ruuuiiinneddd!!!

I cast my weary eye over the options, and finally decided to try the bookmarklet. Dunno why, I guess maybe it sounded simple, or maybe unthreatening in its diminuitiveness. I successfully downloaded an mp4 (high quality) image file by using the bookmarklet – what you do is browse to a webpage that includes a Youtube video (it doesn’t have to be a web page actually on Youtube.com – many bloggers and webmasters have Youtube videos embedded in their own sites) and click on the bookmarklet. The resulting mp4 file played well in vlc, so I’ve got no issues in that regard. But changing the PWNYoutube interface so you no longer get a simple download link – that’s just bad. Shame on you, PWNYoutube!.

PWNYoutube – new interface. Boo!!

So, what’s the new PWNYoutube like? Well the bookmarklet works; I don’t know about the other utilities, if I get round to trying them I will post my verdict here. And I really should make an effort to try it all out. That’s what this blog post is all about, after all. But I’m so pissed off with PWNYoutube at the moment, I just don’t feel like doing it. If PWNYoutube can’t be bothered to provide me with a simple download link that works with wget, maybe I can’t be bothered to give them publicity. Fancy shmancy download utilities just don’t do it for me. I like wget. But PWNYoutube don’t like wget. Which makes it feel like PWNYoutube don’t like me.

YET ANOTHER UPDATE:

Here’s a couple more things relating to online video. First of all, some of the sites I have mentioned previously have become pretty crappy.  Surfthechannel.com is terrible nowadays.  All it seems to offer are links to buy videos from Amazon or watch videos streamed from Megavideo – and if you don’t sign up to become a member of Megavideo, you can’t watch anything longer than about 56 minutes.

But it’s not all bad news.  It has become easier to download videos from tv-video.net, and these downloaded files are in mp4 format and much better quality than the streamed flash videos.  To download these files, you need to use Firefox, and the Firefox add-on Video DownloadHelper.  When you’ve installed Firefox and the add-on, go to tv-video.net and navigate the site to watch the video you want.  When you click on “Play”, you’ll see the DownloadHelper icon change colour and start moving.  Click on the icon and you’ll get a drop-down menu with a number of options.  Choose to download the file.  Once the download has started, close the tab which contains the playing video: the download speed will increase considerably, and you won’t need the crappy flash version.

That’s all for now; but I’ll update this post as and when new video downloading methods come to light.

6 JUNE 2012: ANOTHER BLOODY UPDATE – but its not really a bad update:

The stuff I told you about at the start of this post, about grabbing video files out of the tmp directory, does not appear to work anymore.  Grr!  BUT:  If  you are using Firefox and have the DownloadHelper add-on, go to Project Free TV and select the TV show/movie you wanna save.  Start watching it; when it’s started properly, the DownloadHelper icon will become all colourful and rotating.  Click on that, and select Copy URL.  Now, go to a terminal and type in something like wget -c -O movie.flv then, before hitting Enter, right-click and select Paste.  That will paste in the actual URL of the movie you want.  Hit Enter, and wget will start downloading the movie.flv file (or whatever name you chose) to your Home directory. Note: in that wget command, the -O is a capital letter O, not a zero.  This seems to work with all the sites Project Free TV link with.  Dunno how long the trick will last, so get going while the going’s good!  Oh yeah, one you’ve got wget downloading the file, close the Firefox tab that’s playing the movie.  Otherwise the download will take much longer.  Good luck!!

bmc-purple