Thursday 14 April 2011

Copy flv files from firefox 4

Disclaimer
Downloading copyrighted material is illegal in some places which could include where you live, so make sure you only use this technique to download videos which are legal for YOU to download this would include getting the author's permission or say you lost your user details for a video upload site like YouTube, and there is no facility to retrieve YOUR videos . OK?


That was the disclaimer stuff, well let's start. It would seem in versions > 10.x the flash plugin is actually playing an already deleted file so... lets track down that file.
1) Load the video in a browser, and check the output of the following command @terminal:
$ lsof | grep -i flash
Result:
single line:
plugin-co 25546 alvin 17u REG 8,2 31286337 787220 /tmp/FlashXXepl8fa (deleted)
The output of the cmd gives a file descriptor open to a “deleted” file, /tmp/FlashXXepl8fa so the flash plugin plays the file and immediately deletes the file thus normal nix tools will not be able to access the file in /tmp notice the 17u in your flv file location so here goes.

2) To confirm again type @terminal:
$ ls -l /proc/16864/fd/* | grep -i /tmp/Flash
Result:
single line:
lrwx------ al al 64 2011-04-14 14:08 /proc/16864/fd/17 -> /tmp/FlashXXTep18fa (deleted)

3) To get your freshly cooked flv file again type @terminal:
$ cat /proc/16864/fd/17 > <filenameofyourchoice>.flv
That's it copy the output of the proc file process to a filename and location of your choice.
Hope this helps and does not get anyone in trouble but out of trouble.

4) To speed things put it all in a script.
Idea of script: output the flv file type @terminal:
outflv.sh <yourfilename.flv>

Contents of outflv.sh:

#!/usr/bin/env bash

## syntax: outflv.sh $HOME/Videos/somefile.flv


for flashpid in $(pgrep -f flashplayer.so); do
cd "/proc/$flashpid/fd"
for video in $(file * | grep '/tmp/Flash' | sed 's/\(^[0-9]*\).*/\1/g'); do
cat /proc/$flashpid/fd/$video > $1
done
done