Last Updated: September 09, 2019
· jammer9

Downloading buffered YouTube videos on Ubuntu using terminal

The Problem
Many times we watch a video on YouTube and want to save it.
For that we have to download it again most of the times. Its OK for small sized videos but if the video size is large, downloading again with the help of any download helper or something like that would again consume your bandwidth and result in duplication of your downloads.

Came across a browser independent method on Ubuntu forums to save already buffered YouTube videos in Ubuntu via terminal.

Step 1 : Find flashplayer's pid :

             pgrep -f flashplayer

Let the result you get be xxxx.

Step 2 : Navigate through RAM :

            cd /proc/xxxx/fd
             ls -l

Step 3 : Note down the number associated with '/tmp/FlashXXXXXX (deleted)

Ex : 16 or 24 or whatever... (There can be more than one ... all of them are videos)

Step 4 : copy video to another location

 cp <the_number> <location_where_you_want_to_save>
 Ex :   cp 16 /home/username/10.flv

Make sure to write your own username and save file with .flv extension.

Kudos, Its Done!

The concept behind this being that the buffered videos are saved in RAM for a while and you can retrieve them from there itself rather than downloading again.
There are certain applications those download the videos on one click as they are being played but this results in the duplication, one for streaming & one your download file.

You can also use flashgot addon in Mozilla for the same purpose.

Or to simplify the process, there is a python script StreamingVideoDownloader

Or youtube-dl is also a nice alternative.

It works well when you've buffered it already and haven't closed that tab/window.
The above method works in Ubuntu because you can browse the RAM in Linux & not in windows.
People further interested can browse for other methods (like retrieving it from browser's cache via GUI.