15Nov

Linux, Flash 10, and saving Flash files

Posted by Elf Sternberg as chat, Linux, personal

It used to be possible for Linux users to find and save the movie file from a Flash download with earlier versions of the Flash plug-in.  Flash put the file in the /tmp directory and if you were quick you  could copy it elsewhere.  If you had a plethora of Flash files, you could often find the one you wanted with a simple ls -lt /tmp/Flash* , which sorts the files in order from newest to oldest.

The latest version of Flash does something tricky, though.  It creates a temporary file to hold the Flash object, then, while keeping the handle to the file open, immediately deletes it.  This means that the Flash application can continue to access and use the file until you navigate away from it, but it no longer shows up in directory listings.

However, if you’re really Linux savvy, there are ways around even this little annoyance.

Looking for a Flash movie you’re looking at right now?  First, run this: lsof | grep Flash .  On my computer, the output was:

midori     9206  elf   57u      REG        8,3  10012691     64772 /tmp/FlashXXKoFQgx (deleted)

There’s that noxious little “(deleted)” flag, too.  But you have a hint.  First, your process id in 9206, and the file descriptor is 57.  Now, you can just cp /proc/9206/fd/57 /home/elf/movie.flv and there you go.  File copied.  At least, it’s worked for me the few times I’ve done it recently.

Lsof is a program that lets you identify all the open resources a running program is using. In this case, my running program is midori, a Gecko-using browser with a long history of trying to keep up. By identifying the resource, I can then wander down the /proc tree, getting at the process’s available resources directly. As a user, I’m free to access (and muck up) my own resources without risking anything or anyone else on the system– Linux is good about that.

13 Responses to Linux, Flash 10, and saving Flash files

Erik

November 15th, 2010 at 11:45 am

I’ve had good success in Firefox using the Download Helper plugin (http://www.downloadhelper.net/). In fact, it’s the primary reason I still use Firefox. Works on Linux, Windoze, & OS-X.

On common sites, it’s very good at finding the source files (on YouTube, for example, it will give you the choice of which resolution to save); on sites it’s not coded for, it will notice the start of any streaming video and will let you save it off, presumably by re-submitting a get for the same file that the Flash player is displaying. There are very few sites where it can’t find the correct file to grab..

Not associated with the development, but I’ve had excellent results using it.

John Smith

November 21st, 2010 at 3:37 pm

Thank you so much!

Plenty of videos don’t show up in the cache for Firefox (maybe cause mine is set to 50mb??), and the /tmp trick was always awesome. This is the closest replacement I’ve seen so far and it seems to work swell.

I’ll be linking to this post wherever people ask about this topic. Thanks!

Renato

March 9th, 2011 at 3:14 am

Hi! I’m trying to use your method, with Firefox 4 beta 12 and Flash 10.2 (square) for GNU/Linux in a x86_64, with no luck. I can watch other .flv videos with mplayer. An example:

$ lsof | grep Flash
plugin-co 3694 renato 20w REG 8,19 10947030 1802970 /tmp/FlashXXzGT8FJ (deleted)
$ ls -l /proc/3694/fd/20
l-wx—— 1 renato renato 64 2011-03-09 06:01 /proc/3694/fd/20 -> /tmp/FlashXXzGT8FJ (deleted)
$ cp /proc/3694/fd/20 test.flv
$ ls -l test.flv
-rw——- 1 renato renato 10947030 2011-03-09 07:11 test.flv
$ mplayer test.flv
[flv @ 0x7fa8483ef600]Unsupported video codec (7)
(Many, many times the error above!)
[flv @ 0x7fa8483ef600]skipping flv packet: type 97, size 7627016, flags 0
[lavf] Video stream found, -vid 0
[lavf] Audio stream found, -aid 1
VIDEO: [] 0x0 0bpp 7.500 fps 0.0 kbps ( 0.0 kbyte/s)
==========================================================================
Cannot find codec matching selected -vo and video format 0x7.
Read DOCS/HTML/en/codecs.html!
==========================================================================
==========================================================================
Requested audio codec family [wma9spdmo] (afm=dmo) not available.
Enable it at compilation.
Requested audio codec family [wma9spdshow] (afm=dshow) not available.
Enable it at compilation.
Cannot find codec for audio format 0xA.
Read DOCS/HTML/en/codecs.html!
Audio: no sound
Video: no video

Renato

March 28th, 2011 at 6:22 am

Got it!

I think it has something to do with having both Flash 10.2 “square” (which AFAIK is required for Flash on 64 bits browsers) AND gnash on the system. A small example to show how to get it right on my system:

$ lsof | grep delete | grep tmp
gtk-gnash 4131 renato 6u REG 8,19 149610 1802814 /tmp/tmpfkbqLyZ (deleted)
gtk-gnash 4131 renato 12u REG 8,19 8470848 1802900 /tmp/tmpfNDLV7j (deleted)
$ cp /proc/4131/fd/12 /home/renato/teste.flv
$ mplayer teste.flv

Works perfectly! I guess that the “trick” to get your method “generalized” is to grep the output of lsof by the string “deleted”, because having gnash installed means I sometimes get a /tmp/tmp* file deleted, sometimes a /tmp/Flash* file.

Anyway, I’m very happy, because I never got Flash to fullscreen correctly on firefox in x86_64, but now I can watch stuff without squinting my eyes.

liu chiu

May 22nd, 2011 at 1:55 pm

Very Good. It works fine for me.

anon

July 2nd, 2011 at 7:16 am

Here is a little script based on this, I am sure it could be improved.

export COUNT=0
export FILENAME=$1
export FILENAME=${FILENAME:=test}

FLASH=`lsof | awk ‘{ if ($0 ~ /Flash/) {split($4, a, “[[:alpha:]]”) ; print “/proc/”$2″/fd/”a[1]}}’`

for N in $FLASH ; do
COUNT=$(($COUNT+1))
cp $FLASH ${FILENAME}_${COUNT}.flv
done

anon

July 2nd, 2011 at 7:17 am

export COUNT=0
export FILENAME=$1
export FILENAME=${FILENAME:=test}

FLASH=`lsof | awk ‘{ if ($0 ~ /Flash/) {split($4, a, “[[:alpha:]]”) ; print “/proc/”$2″/fd/”a[1]}}’`

for N in $FLASH ; do
COUNT=$(($COUNT+1))
cp $FLASH ${FILENAME}_${COUNT}.flv
done

Geoff

August 8th, 2011 at 5:13 am

Hi,
I’ve just started using Midori and the lsof + cp method works fine in YOUTUBE.
I was just wondering what might be different about DAILYMOTION, since when I
enter the “lsof | grep Flash” command there is no output.
I wouldn’t know where to begin to investigate..

janidotux

September 3rd, 2011 at 4:46 pm

It worked fine for me!!! Thanks for this tip!!! Linux Rocks!!!

Paul

November 18th, 2011 at 10:43 am

The original post will also work for HTML5 video, for example from YouTube. Instead of Flash, you grep for mozilla-media-cache:

lsof | grep mozilla-media-cache

firefox 15097 user 164u REG 254,1 255524864 4199890 /tmp/mozilla-media-cache/media_cache (deleted)

Jonathan Sch

March 18th, 2012 at 3:23 pm

Awesome Post, I was looking all over the place to find out where Adobe was hiding its Flash videos. Thank you!

Automatically saving Flash 10 video files marked as (deleted) | tjansson.dk

August 2nd, 2012 at 12:10 am

[…] http://www.elfsternberg.com/2010/11/15/linux-flash-10-saving-flash-files kb9rlw.blogspot.dk/2011/11/download-any-flash-video-you-can-view odzangba.wordpress.com/2011/10/18/how-to-download-flash-videos-on-ubuntu-11-04 ikacikax.wordpress.com/2011/03/06/where-are-chromes-flash-temporary-files-ubuntu n00bsys0p.wordpress.com/2011/02/10/how-to-download-flash-10-2-video-streams-in-linux This entry was posted in Articles, Computer. Bookmark the permalink. ← Disable mounting /tmp as a tmpfs […]

Ferk

January 31st, 2013 at 10:54 am

This doesn’t work anymore with flash 11. Any idea how to do it with the newest version?

Comment Form

Subscribe to Feed

Categories

Calendar

November 2010
M T W T F S S
« Oct   Dec »
1234567
891011121314
15161718192021
22232425262728
2930