I found a script on the internet that allows me to save cached flash files.


This would allow me to run the command saveflash in a terminal to list flash videos and filesizes. And then I could run something like saveflash -n 2 nameofvideo.mp4 to save it. I even added the capability to demux the audio out of the video.

I'm trying to do the same for non-flash videos that are cached by firefox. I would like a command, or set of commands that I can run to list the video files and then save them.

It's a little more convoluted. I have to use lsof to list open files, find ones that have a suitable filesize and then get the proc and fd to use for the copy command.

Right now, I do it manually, running a command like this:

lsof -c firefox | grep -i deleted

The lsof command takes a few seconds to complete. And then I have to manually put together the copy command based on what the lsof command says that the pid and fd of the file is, then I would do a command like:

cp /proc/3164/fd/55 "~/Videos/Name of Video.mp4"

What's the best way to speed up/simplify this process? I'd like to make it into a script eventually.


When you take a look at the mentioned bash script you find the following commands beeing used:

awk, cut, cp, ffmpeg, file, ls, sed, test, wc

You should figure out what they do to automate your manual processing with bash.

Alternative and possible faster ways of getting the pids of firefox is to use pgrep firefox or pidof firefox which may take less time than lsof -c firefox.

Sometimes it's not neccessary to reinvent the wheel. Tools like youtube-dl (based on python) are available to download videos from many video plattforms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.