Pages

Tuesday, January 17, 2012

Download Flash (.flv) Videos on Ubuntu

Whenever we watch a flash video (such as over You Tube or any other sites), the flash video file gets stored in the temp folder or browser's cache temporarily. We can store those files into our file system for watching it later. First make sure that the video has been completely streamed on your browser and the tab in which the video was playing hasn't been closed. The temporary flash file gets deleted once you close the tab in which the video had been opened. So its necessary not to close the video before completing the steps below.
  First we need to locate the flash video file on our system. For locating the temporary flash video file, use the command:
    lsof | grep -i flash
For detailed documentation on "lsof" command, check the man pages. 
It will give an output like:
"chromium- 1674 shekhar mem REG 8,1 17047244 13128 /usr/lib/adobe- flashplugin/libflashplayer.so"
"chromium- 1761 shekhar mem REG 8,1 17047244 13128 /usr/lib/adobe- flashplugin/libflashplayer.so"
"chromium- 1761 shekhar 22u REG 8,1 8046003 9222 /tmp/FlashXXopqyZk (deleted)"
 The third output line (the one with darkest background color in my case) indicates that the file is somewhere in the /proc directory. Using the process id 1761 (the second field in the output of lsof command), we can find the file FlashXXopqyZk in the /proc directory.
For finding the file use the command:
$  cd /proc/1761/fd ; ls -l | grep FlashXXopqyZk
The output of the above command would be something like:
 lrwx------ 1 shekhar shekhar 64 2012-01-17 09:36 22 -> /tmp/FlashXXopqyZk (deleted)
The above output indicates that the flash video file is named 22 (the field indicated in bold and large font in the above output) and is linked to /temp/FlashXXopqyZk (deleted). Now we just need to copy the file from the /proc directory to our home directory. For copying the file to the Videos folder in your home directory, use the command:
$  cp 22 ~/Videos/filename.flv
And we are done. Navigate back to your Videos folder and watch the video.