Tech Tip: Save an Online Video with your Browser (no extensions needed)
Sometimes when you're watching online videos on youtube or other sites, you want to save some of them for later offline playback. You've probably heard of Firefox extensions like DownloadHeloper that can do this, but sometimes you may only have a bare version of Firefox, or perhaps a different browser, one that doesn't have a plugin for doing this. Using the tip below, you can save videos no matter what browser you're using.
First, find the browser process id:
$ ps xfa | grep firefox # or grep any other browsers' name
Say, we get 12279. Note that you may get more than one result from the above command: you need the process id of the binary executable. The firefox command, for instance, is normally a script which starts the real binary.
Then, list its opened files, by:$ ls -lU /proc/12279/fd
This will show you the files opened by the process, there may be a lot of them. The file name is the file descriptor number, it is a symbolic link that points to the real file that is opened on that file descriptor. The output will look something like:
# NAME REAL FILE lrwx------ 1 grp usr ... 59 -> socket:[3372642] lrwx------ 1 grp usr ... 62 -> /home/gektop/.mozilla/firefox/u824gy5z.default/signons.sqlite lrwx------ 1 grp usr ... 70 -> /tmp/moz_media_cache (deleted) lrwx------ 1 grp usr ... 73 -> /home/gektop/.mozilla/firefox/u824gy5z.default/places.sqlite-journal lrwx------ 1 grp usr ... 74 -> /tmp/FlashZzxRDM lrwx------ 1 grp usr ... 75 -> /var/tmp/etilqs_5I5bzLh21aIoh4a (deleted)
Now look for names matching the pattern "/tmp/Flash??????". In the above example, we see /tmp/FlashZzxRDM. This is really a .flv file, you can open it with mplayer or any other video player and see that it is a video. If you see more than one file you may need to try playing them to see which one you're looking for.
The last step is to simply copy the file to your home directory, renaming it in the process (e.g. "jackson.flv"). Wait till after the browser has played the entire video, otherwise you may get an incomplete file.
__________________________Cheng Renquan, Shenzhen, China
Submitted by Cheng Renquan on Wed, 2009-10-28 08:00.
Delicious
Digg
StumbleUpon
Reddit
Facebook
My take on this
#!/bin/bash # find currently playing flash video and save it # based on suggestion at # http://www.linuxjournal.com/content/save-online-video-browser-no-extensions # my standard place to store videos VIDEO_DIR="$HOME/tma/Videos/" if [ $# -eq 1 ]; then # get pid of firefox FF_PID=`pidof firefox` # get name of flash file FLASH_FILE=`ls -lU /proc/$FF_PID/fd | grep tmp | awk '{print $10}'` # get rid of /tmp/ in front of FLASH_FILE FLASH_FILE=`echo $FLASH_FILE | sed -e 's?/tmp/??'` # store flash file in VIDEO_DIR cp /tmp/$FLASH_FILE $VIDEO_DIR/$1.flv else echo 'Usage: grab_flash_sh (w/o extension)' fi exit 0YouTube with no sound
The Tech tip works for most of the short videos that I have tried, but anything from youtube has the sound turned to white noise. Is there a way around this?
even easier
apt-get install -t lenny-backports clive
Then:
clive http://www.youtube.com/watch?v=whatevergobbledegook
More info on Flash players + videos
1) Some Flash players use the browser's cache so all one has to do is dig around under ".mozilla" (FireFox / SeaMonkey / other Mozzies), ".opera", ".netscape" (Navigator 9), etc. Use your file manager (Konq. / Nautilus / etc.) in reverse chronological order so that the most recently changed files are near the top.
I didn't know about fishing around in "/tmp". Thanks for the tip - I'll be trying it in the next day or so.
2) My usual way of playing ".flv" files is to use the Kaffeine front-end to xine. Due to the age of my distro (SUSE 10 Book) I also have MPlayer (".mov" + DVD's) and Ogle (DVD's) installed. KLUDGE CITY !
3) Google is also very useful because it can lead you to sites like "get2pc.com". That site is a somewhat flaky leech aimed at YouTube + clones. If you go there keep your eyes open for strange, new tabs opening in your browser. That's why I'm not providing a link - I don't want careless surfers getting trapped in web crud.
Paths (sample## is a placeholder - look for a weird folder name):
FF - ~/.mozilla/firefox/sample12.default/Cache
Moz. - ~/.mozilla/default/sample34.slt/Cache
Nav. - ~/.netscape/navigator/sample56.default/Cache
Opera - ~/.opera/cache4
Cache Info. - about:cache (Moz.-type) or opera:cache
one liner
RIP=$(ls -lU /proc/`pidof firefox`/fd | grep Flash | cut -d'>' -f2 | cut -d' ' -f2); echo $RIP; cp $RIP rip.flv; unset RIP;
you have to have only one flash movie playing
Might need pid of npviewer
On my opensuse system I found that the file is opened by npviewer.bin instead of firefox, so when you find the pid, check for npviewer.bin as well.
cool.. but what about
cool.. but what about streaming flash video?
Scripts
I posted some quick scripts for both Linux and OS X based on this article. You can check them out at www.standardload.org if anyone is interested. If you fix them or improve them, please post back!
Thanks! This is a great tip.
My script
I made a script that saves videos from the /tmp directory. I then added it to my top panel, and when clicked a zenity GUI box pops up and asks what I want to name my vid. Here is the script below. Go easy on me, it was the first script I ever wrote ; )
#!/bin/bash count=$(ls /tmp/Flash* | wc -l) function cancel { if [ "$?" = 1 ]; then exit 1 fi } if [ "$count" = 0 ]; then /usr/bin/zenity --error --title="ERROR!" --text="There is no video in your /tmp directory! exit 1 elif [ "$count" != 1 ]; then /usr/bin/zenity --error --title="ERROR!" --text="There are two or more instances of a .flv video in your /tmp directory, Nautilus will now open. Please select the video you want to save." nautilus /tmp/ else name=$(/usr/bin/zenity --entry --title="Name your Video" --height=100 --width=300 --text="Please name your video ") cancel cp /tmp/Fla* ~/Videos/"$name" filsof
When I wanted to temporarily save a copy of a video I found on-line, I used lsof to find the open files:
$ lsof | egrep "^firefox"
firefox 1160 username cwd DIR 8,1 12288 5128194 /home/username
firefox 1160 username rtd DIR 8,1 4096 2 /
firefox 1160 username txt REG 8,1 30232 3784876 /usr/lib/firefox-3.0.14/firefox
firefox 1160 username mem REG 8,1 88704 3745430 /usr/lib/libbeagle.so.1.0.2
firefox 1160 username mem REG 8,1 96324 3842741 /usr/share/mime/mime.cache
firefox 1160 username mem REG 8,1 68801 3907635 /usr/share/fonts/type1/gsfonts/n019024l.pfb
firefox 1160 username mem REG 8,1 320764 3893378 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf
<...snip...>
Firefox opens a lot of files, so you might want to massage the data a little:
$ for File in `lsof | egrep "^firefox" | awk '{ print$9 }' | grep "^/"` ; do IsVideo=`file ${File} | grep -i video` ; if [ "x${IsVideo}x" != "xx" ]; then echo "${File}" ; fi; done
/tmp/plugtmp/plugin-TT103%20-%20zsync.ogv
/tmp/plugtmp/plugin-TT103%20-%20zsync-1.ogv
$
Superb
With this article and the suggestions from readers, plus the command
pidof firefox
one should be able to produce a script quite easily that does it all with a click. Just make sure there is only one video running at a time (why would you need more?)
Use hard links !
I use this trick, but without searching the files opened by the process. I simply knew that the last file beginning with Flash* in the /tmp directory was the one I needed.
But this file is deleted immediatly after leaving the html-page where the player is included.
So, with large files, when the download begins (you can see the file growing with $ls -l /tmp/Flash*), I create a hard link in my home directory:
$ ln /tmp/FlashZzxRDM foo.flv
You know; a file is'nt really deleted until the last name subsists for it. You can now see both files growing in parallel.
When the process deletes the file in /tmp, you still have it in your home :)
Scrap my last comment - this
Scrap my last comment - this is way simpler:
(replace 27164 with the process id of your browser)
ls --color=none -lU /proc/27164/fd | awk '{print $NF}' | xargs file
If the browser saves the
If the browser saves the file with a name other than /tmp/Flash???, you can still identify video files with the Linux "file" command.
In the following command, replace 27164 with the process id of your browser, as described in the original article.
for file in `ls --color=none -lU /proc/27164/fd | awk '{print $NF}'`; do file $file; done
Any output file that has a description of the form "Macromedia Flash Video" or "Video" is probably one.
why so complicated ?
you can simply type" about:cache" in the url and select your video file. There is also a plug-in for that here
You must be a Ubuntu user. LOL
Just kidding man.
tmp directory
Or you just go to /tmp directory and flv file is there ;-)
Look forward to Ogg Theora becoming de-facto standard
This is an oldie, but goodie, and it is a good way to save Flash video files, true. But I don't care for Adobe's buggy player, nor for their legal stance on the file format.
Fortunately, Firefox 3.5 includes Ogg Theora streaming right out of the box, so hopefully video publishers will start adopting it and saying "please install Firefox to view this content." Let's continue to promote this option.
--TP
cool trick
such an unorthodox method of doing this! love it, nice and technical.
Post new comment