29

In Maverick, there was an option to download Flash videos from sites like YouTube, Vimeo, etc. by copying the flashxx** file in /tmp directory to another location before closing the window. But in Firefox 4 in Natty, this doesn't work anymore. Why?

2

21 Answers 21

28

You can use several Firefox addons in order to extract the FLV files from many websites such as Youtube.

I'll show below how to do this MANUALLY with the latest version of the Flash plugin.

  1. Visit the YouTube video and wait for it to be downloaded fully.
  2. Then, run from the command line the command

    $ lsof -n | grep Flash

    which shows the files (even memory files!), and filters to those that have Flash in their name.

  3. You get something like

    plugin-co 2461 user 17u REG 8,5 1693301 524370 /tmp/FlashXXVkHEM6 (deleted).

    Now, there is a /tmp/FlashXXVkHEM6 but it has been deleted.

  4. In Linux, if a file is deleted, it is actually gone only when all programs that opened it earlier are closed. That is, the Flash plugin is using a trick to hide the /tmp/FlashXXVkHEM6 file. It creates it and immediately deletes it. But since the Flash plugin keeps running, it can apparently still use it.

  5. From the above line we note the number 2461, which is the process ID. In your case it will be probably different. Then, run

    $ cd /proc/2461/fd

    and finally execute

    $ ls -l

    This will show you the memory files, and specifically

    lrwx------ 1 user user 64 2011-09-16 10:23 17 -> /tmp/FlashXXVkHEM6 (deleted)

    The number '17' (in my case) is the filename you can use to access the deleted /tmp/FlashXXVkHEM6. Therefore, simply run

    $ cp 17 /tmp/myyoutubevideo.flv

    and you restore the Youtube Video!

That's it! You manually recovered the Youtube video!

26

An update to the flash plugin changed the location from /tmp to the Firefox cache directory (e.g. ~/.mozilla/firefox/bq95m4w1.default/Cache). Unfortunately the cached flash file is not as easy to find as before, but it is possible.

The following command lists all the flash files in your Firefox cache.

find ~/.mozilla/firefox/*.default/Cache -type f -exec file {} \;  | grep Flash

On Newer versions of ubuntu try

find ~/.cache/mozilla/firefox/*.default/Cache -type f -exec file {} \;  | grep Flash
4
  • 1
    Why not file ~/.mozilla/firefox/*.default/Cache/* | grep Flash? Cache directory does not seem to have subdirectories, that could justify the use of find.
    – enzotib
    May 30, 2011 at 20:42
  • doesn't work. probably worked before.
    – dumb906
    Sep 13, 2011 at 11:57
  • The FLV file is still in /tmp, however you need a special trick to access it.
    – user4124
    Sep 16, 2011 at 9:24
  • See my reply below which talks about recovering the FLV file using the /proc filesystem. Still, you can use one of the Firefox addons to perform the same task.
    – user4124
    Sep 16, 2011 at 9:37
7

If you navigate to your /proc folder, you will see a bunch of folders all named numerically, including a folder which matches the number in the second field.

Now navigate to this folder, then its subfolder “fd”. In this folder, you will see a whole selection of numbers. These relate to the file descriptors themselves.

Run ls -l in this folder, and you will see that each of these numbers is linked to either pipes, sockets or files.

Within this, the number from the fourth field will be symbolic linked to the /tmp/Flash* file we found before.

To test that this is the right file, you can run it through mplayer or vlc (mplayer filedescriptornumber/vlc filedescriptornumber). If you’re having trouble finding the filename, try ls -l | grep Flash.

For easy way try this command in console:

stat -c %N /proc/*/fd/* 2>&1|awk -F[\`\'] '/Flash/{print$2}'

The output will be something like this:

/proc/4691/fd/17
/proc/4691/fd/18

That will list all your downloaded flash streams. For that example, there are 2 flash videos from my firefox 4 browser. If you want to copy it, simply use this command:

cp /proc/4691/fd/17 ~/Videos/Flash/sample.flv

Source: http://n00bsys0p.wordpress.com/2011/02/10/how-to-download-flash-10-2-video-streams-in-linux/

5

This little script would save your downloaded flash files to a custom directory.

  1. make the directory of where you want the files to be saved eg ~/Videos/flvs

    mkdir ~/Videos/flvs
    
  2. open gedit and copy and paste this script.

    #!/bin/bash
    # flvcache script
    
    CACHE=~/.mozilla/firefox/*.default/Cache
    OUTPUTDIR=~/Videos/flvs
    MINFILESIZE=2M
    
    for f in `find $CACHE -size +$MINFILESIZE`
    do
        cp "$f" "$OUTPUTDIR/$o"
    done
    
    nautilus  "$OUTPUTDIR"&
    
  3. save the file as saveflashall.sh, then add executable permissions to the file

    chmod +x saveflashall.sh
    
  4. then run it.

    ./saveflashall.sh
    

it would then open the files in the first folder created above. Customised to include all files ( worked for mpeg and mp4) instead of only flvs.

Credits goes to http://desdecode.blogspot.com/2011/04/saving-watched-online-videos-linux.html

1
  • I tried this..some videos which I've watched a long back are now in this folder but the ones I watched right now aren't. Why?
    – avi
    Sep 17, 2011 at 21:36
4

As far as i know this is not due to firefox nor natty, but a flash update...

You can catch the http stream with wireshark or use a tool like youtube-dl to get the movie file.

But remember that it might not be legal, so check your local legislation...

1
  • Neat trick with the wireshark, but I guess this may be tiring, as the videos are quite large in size (more than 10MB), while packages come with a tiny piece of that data:) Apr 14, 2012 at 12:57
3

You should use flashgot to download the videos.

3

Ubuntu 12.04 (Precise) - Firefox 11 Instructions A modified version of chlumma1's bash script.

With a text editor, save the code below into file named "getvids.sh". Move it to the location you want to save videos. Right-click on the file, go to Properties, Change the Permissions to "Allow executing as a program".

All you have to do is click the script, select "Run in Terminal", and it will save all video files to that directory. To save the whole video, it has to be finished loading in your browser. It will save videos from almost any website, including youtube, vimeo, dailymotion, metacafe, liveleak, facebook. Just delete any video files you don't want.

(If a video you want is not getting saved, then the website is probably using a proprietary stream format that can't be saved by any cache retrieving program. Examples: Hulu, netflix, some youtube videos?) Also, VLC player is a great for watching flash videos.

#!/usr/bin/env bash
# getvids.sh [save_folder]

SAVE_FOLDER="$HOME" # User editable

# If the below option is used, then this script should be run in a terminal.
#CPMOD="-i" # Uncomment to prevent file overwrites

PATERN="libflashplayer"
ALL_PID=`pgrep -f $PATERN`

if [ $? -eq 1 ]; then
  echo ERROR: Flashplayer not running
  exit 1
fi

if [ ! -z $1 ]; then
  echo "Setting save location: $1"
  SAVE_FOLDER="$1"
fi

if [ ! -d "$SAVE_FOLDER" ]; then
  echo "Save location doesn't exist: $SAVE_FOLDER"
  exit 1
fi

for PID in $ALL_PID; do
  declare -a OUTFILES=($(ls -lt1 /proc/$PID/fd | grep '/tmp/Flash' | sed 's/^.*\/tmp\///' | sed 's/\ .*$//'))
  declare -a FDS=($(ls -lt1 /proc/$PID/fd | grep '/tmp/Flash' | awk '{ print $9 }' ))
  for ((i=0; i<${#FDS[@]}; i++)); do
    saveas="$SAVE_FOLDER/${OUTFILES[i]}.flv"
    echo "Copying video ${FDS[i]} to $saveas"
    cp $CPMOD "/proc/$PID/fd/${FDS[i]}" "$saveas"
  done
done

Those who know a bit about the terminal can edit the first two variables and achieve a little extra functionality. Alternatively, to view the files live, you can type this in a terminal to find out where they are for i in $(pgrep -f libflash); do find /proc/$i/fd/ -ls | grep "/tmp/Flash" | awk '{ print $11 }'; done

PS. Also, excellent work chlumma1, but lay off the C programming style loops a bit ;)

2

Recent versions of the flash plugin hide the temporary file by marking it deleted. Practically the video stream is downloaded to a "deleted file". However, even when a file is deleted, if the file is opened by a process then you can find its file descriptor and consequently the file contents.

This simple script prints out the file descriptors of opened Flash videos:

file /proc/*/fd/* 2>/dev/null | grep Flash | cut -f1 -d:

And, you probably want to create a regular file from the file descriptor, for example:

cp $(file /proc/*/fd/* 2>/dev/null | grep Flash | cut -f1 -d: | head -n 1) video.avi

Otherwise the file descriptor is not very convenient (remember, it's a deleted file!)

The method should work regardless of your browser.

1

Hey, this problem already existed in 10.10. So in order to solve it try this:

None of the methods described by previous posters are as convenient as just copying the flash file from the tmp directory.

Therefore, what I did was downgrade my Flash to 10.1.102.64

The download link for older versions of flash is http://kb2.adobe.com/cps/142/tn_14266.html

Download the (large) file named "Flash Player 10.1.102.64 and 9.0.289.0".
After downloading, extract the file named flashplayer10_1r102_64_linux.tar.gz

From this file extract libflashplayer.so and overwrite the file at /usr/lib/flashplugin-installer (you will need root privileges, try gksudo nautilus)

Restart Firefox and your flash videos will land up in the /tmp directory as before! This won't work for Google Chrome, it will continue to use the latest version of Flash.

Note: For the above steps to work, a version of Adobe Flash should have been previously installed.

[quoted from this site: posted by chetancrasta View Post]

I hope this will help you. Let me know if this'll work.

2
  • I think you misunderstood the question. The original poster already has Flash Player installed and working. He is just wondering where Flash stores its temp files. Apr 29, 2011 at 8:01
  • Ya. Right. But i think he is wondering, where the flash files are gone. With the new adobe flash player version, they are stored like @Woozy already mentioned. @Woozy also mentioned that the "cached flash file is not as easy to find as before". So if you want the flash file find "easy" again, you can downgrade your flash player. Consequently the flash files will be stored in /tmp again...I hope you understand my point now!? Or am i wrong ?
    – Vito
    Apr 29, 2011 at 8:10
1

For a generally applicable method which works with chrome or firefox try this little program called flashcache. It copies flash videos currently being played back to the current directory.

My patch adds the option -p which makes the script play back the videos using mplayer instead of making copies of the files.

1

Although not directly answering the question, I ran into the same issue and after some searching found Clipgrab which is much easier to use.

1

You can try this command in a terminal

cp \`file /proc/\*/fd/* | grep tmp/Flash | awk -F":" '{print$1}'` dirname/
1

follow this link (~/.mozilla/firefox/ewzggcll.default/Cache)

Unless I'm really confused (don't think so), that "ewzggcll" will not be in your machine. What you will find there is a random collection of letters (and possibly numbers?) that's very likely to be unique to your Linux and Firefox installation. Nevertheless, this odd-looking random collection is important, because it's essential for getting at the cache[s].

Hope this helps! (HTH)

1

I use SMplayer YouTube. It comes with Smplayer that you install in ubuntu software center. It record youtube videos. very simple and easy to use.

1
  • I can confirm that this WORKS. Ubuntu 14.04. I can't believe I wasted my time trying all answers here and everywhere else on internet with NO SUCCESS until I came to this... Just searched SMPlayer in the software center, installed it, pasted the yt address, and saved the video, in the format and size of my choice... :D
    – PFROLIM
    Sep 25, 2014 at 19:14
1

I use minitube, a youtube client that STORES flash files on /tmp

1

This script will do that:

#!/bin/bash
PATERN="libflashplayer"
ALL_PID=`pgrep -f $PATERN`

if [ $? -eq 1 ]
then
echo ERROR: Flashplayer not runnig
exit 1
 fi


 for PID in $ALL_PID
 do

OUTFILES=`ls -lt1 /proc/$PID/fd | grep '/tmp' | sed 's/^.*\/tmp\///' | sed 's/\ .*$//'`
INFD=`ls -lt1 /proc/$PID/fd | grep '/tmp' | cut -f 9 -d \ `


# nazev souboru do pole
i=0;
for out in $OUTFILES
do
    i=`expr $i + 1`
    NAMEFILE[$i]=$out

done

# nazev file desktiptoru do pole
i=0;
for out in $INFD
do
    i=`expr $i + 1`
    NAMEFD[$i]=$out
done



# ulozeni video dat
i=0;
for outfd in $OUTFILES
do
    i=`expr $i + 1`
    #echo ${NAMEFILE[$i]} ${NAMEFD[$i]}

    cat /proc/$PID/fd/${NAMEFD[$i]} > ${NAMEFILE[$i]}.flv
done

done
0

Mozilla seems to change the location too frequently. Further, the name of buffer is not the same as the video, so finding out the corrent one from the heap is also difficult. So saving the cached file is not a consistent solution. If installing a desktop program is ok, ClipGrab is the best tool out there. You can

  1. Search for videos.
  2. Select quality of youtube video to download.
  3. Select format of video to download.
  4. You can just give a youtube video URL and it will download the file.

ClipGrab to download youtube videos in Ubuntu.

0

You can also use keepvid.com for many video streaming sites. It does require java to be on your machines though. Once installed simply paste in the url link and save it in a variety of formats including mp4 or WebM

0

easiest method is to use the "CacheViewer Continued 0.8" addon for firefox

after installing press ctrl + shift + c to open and then press show all , there after u can search for a particular cache like jpeg , flv anything ......left click on the item will give u the option to save , save it by giving the required extension like .flv for flash video and .jpeg for jpeg and vice versa enter image description here

link for the addon https://addons.mozilla.org/en-US/firefox/addon/cacheviewer-continued/?src=api

0

Thats still possible.

You can use the shell script from this post about how to open/play all Flash videos with VLC.

To copy all of the videos you have to replace in the last line of the script vlc by cp and provide a destination directory at the end of the same line.

-1

Hope this will help you http://sahanlm.blogspot.com/2012/05/how-to-copy-google-chrome-cache-flash.html

1
  • 1
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. May 2, 2012 at 20:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .