Download YouTube or Other Flash Videos in Linux

by Stephen Fluin 2012.03.19

Internet Videos are everywhere. As of 2012, they make up the majority of the content being transferred across the internet. Occasionally you want to make a backupcopy of one of these videos for you personal collection. This is relatively easy in Linux due to how everything is handled in a standardized way, so I'm going to share the scripts I use to do this.

Play open Flash videos in VLC

One of the most common use cases for me is to want to take a video that is playing in Flash, and move it over to VLC. With VLC I have much better control of full screen, video size, pausing, navigating within a video, etc.  To immediately launch vlc with the video currently playing in flash, I execute the following script out of /usr/local/bin/, called vlccurrent.

lsof -p `pgrep -f flashplayer` | grep '/tmp/Flash[^ ]*' | awk '{ print "/proc/" $2 "/fd/" $4 }' | sed 's/[rwu]$//' | xargs vlc

Get Filename of Current Flash Video

Another common use case is to want to copy the filename of the currently playing video. Keep in mind that this will only work after the video has finished buffering. Copying the video before it has buffered will result in not copying the entire video.  This may break if YouTube more fully changes to HTML5 or webm formats, but has worked for more than a year now. Here are the contents of vlcl:

#!/bin/bash
lsof -p `pgrep -f libflash` | grep '/tmp/Flash[^ ]*' | awk '{ print "/proc/" $2 "/fd/" $4 }' | sed 's/[rwu]$//'

With this script I am able to do the following

cp `vlcl` ~/new-video-name.mp4

 


permalink