How To: Save flash (.flv) files within Linux

THE BELOW IS OUTDATED

Have you ever watched a youtube.com video and then wanted to save a copy of it to your hard drive so that you can view it later only to find that you can't because there is no download link? You're in luck as the following How To: Save flash (.flv) files within Linux article describes it step by step.

While the the older version of Adobe Flash Plugin (10.2) used to save all flash files (.flv) files in the /tmp directory where, one was able to view and copy them once they had buffered (fully loaded). The new version of the Adobe Flash Plugin (10.3) tries to be a little more clever. It now only creates the files inside the /tmp directory, deleting them immediately while still keeping them open within the browser. This allows the flash plugin to still use them, while disabling anyone from saving them. In Linux however, if an opened file is deleted, deletion of the file is postponed until the process using the file releases it.

So having a look at all the process's using the flash plugin on your system it's easy to spot the process that is linked to the deleted flash files.

f......@h...s $ ps x | grep flash
1783 ? Sl 35:23 /usr/lib/chromium-browser/chromium-browser --type=plugin --plugin-path=/usr/lib/adobe-flashplugin/libflashplayer.so --lang=en-US --channel=1707.0xbb01c420.430497743


Once you find the process that links to your deleted flash files you can find it's file descriptors inside the /proc directory by;

f......@h...s $ ls -l /proc/1783/fd
lrwx------ 1 dknezev dknezev 64 2011-06-27 14:08 24 -> tmp/FlashXXF1NltO (deleted)


Finally you can copy them to your home directory by using the process id;

f......@h...s $ find -lname "/tmp/Flash*" -exec cp {} /home/#######/videos \;

Easy as saying one, two, three. One could trivially write a shell script that does this automatically too, which I have gone and done for you.

#!/bin/bash
#
# ©© Except where otherwise noted, this content is licensed, under a
# Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported
# License.
# http://creativecommons.org/licenses/by-nc-sa/3.0/
#
# File: save_flash.sh
# Usage: ./save_flash.sh
#
# Options: ---
# Requirements: ---
# Bugs: ---
# Notes: ---
# Author: Damir Knezev (damir@knezev.com)
# Twitter: dknezev
# Company: Knezev Inc.
# Facebook: http://www.facebook.com/knezev
# Version: 1.0
# Created: Mon Jun 27 13:58:57 EST 2011
# Revision: ---
#
# Description : Bash script to save flash (.flv) files.
#

# Store the Process ID responsible for the flash plug-in within Chromium.
PROC_ID=`ps x | grep flash | grep adobe | awk '{print $1}'`;

# Access the process's open file descriptors in /proc.
cd /proc/$PROC_ID/fd

# Find all the flash (.flv) files within the directory and save them to
# your home directory.
find -lname "/tmp/Flash*" -exec cp {} /home/#######/videos \;

4 comments:

  1. Well I am using 11.04 and flash 10.3 and this trick does not work on following link
    http://drupalize.me/videos/introduction-theming-basics-drupal-7

    it uses rtmp protocol to stream.Any guess what next can we try?

    ReplyDelete
  2. Not working anymore since April 2012

    ReplyDelete
  3. Can you please leave me a few details about your OS and the sites that you are trying to save flash files from. Thank you.

    ReplyDelete
  4. Storage mechanism must have changed again. With FF13 and flash 11.2 r202 youtube videos are not found in /tmp or in the browser's cache.

    ReplyDelete