Thursday, December 1, 2011

Download cached flash videos of Firefox and Chrome in Linux(Ubuntu)

In recent days, you could feel that the played Flash videos is no longer available in /tmp directory like some time before. This was the easiest way to get the video that was played just before completely on any browser from such Flash playing sites like Youtube. Now we can't use the same olden ways.
Here is an alternate way to get the video by doing some workaround.

By default, while executing any commands or application, Linux maintains a copy of the files that process using currently untill the process get closed or killed manually. These files are kept under a  unique directory with the name of that process id under /proc folder. Now you may got the idea i think. Yes, we need do the following thinks to find the exact path by finding the process id of the browser we are using. You may use any browser, but the concept is same.

To find the process id ( -i means case insensitive on search) ,

$ lsof | grep -i flash
This will yields the result like,

              chromium- 3111   csenthil   25u      REG       8,23     26852199      66502 /tmp/FlashXX7qfvPA (deleted) 

From the result, we can conclude that the process id of the browser (here 3111). Next step, we need to list the all Flash files under the process by using the following command.
$ ls -al /proc/3111/fd | grep deleted 
This will yields the result like (lists more files when you running more than one player instance),

              lrwx------ 1 csenthil csenthil 64 2011-12-01 20:57 25 -> /tmp/FlashXX7qfvPA (deleted)

From that, we can can conclude that the expected file resides there in the name of 25. Then why are you waiting for... Just copy the file where ever you want like,  
$ /proc/3111/fd/25 /home/csenthil/Desktop/saved.mp4

Note: This is tested under Ubuntu 11.04