Downloading embedded flash: Combining f4f files and converting to .mp4

Note: I’m using Ubuntu to do the downloading and converting.

I needed to save a video from a website, and the video was embedded with Flash.  I found that the video was being streamed to Chrome in 14 different segments.  The file extension for the files is .f4f, which is not easily playable or suitable for archiving, so just downloading them is not enough – but that’s where we’ll start.

In Chrome, click Tools > Developer Tools and then the Network tab to see a list of f4f files that are being streamed to your computer.  (click size to organize by filesize and have the video files appear on top).

Once you have that pulled up, start playing your video, and you should see the video files appear at the top.  You can see the few f4f files that Chrome is loading in this screenshot:


Right click one of those, and copy the URL.

You’ll probably get a long link on your clipboard, with something like “Seg1-Frag2” at the end.  Segment 1, Fragment 2, is what that means, obviously.  You’ll need to download all of those fragments.

Grab a few utilities first that you’re going to need

sudo apt-get update
sudo apt-get install wget php libav-tools

With those installed, let’s download the fragments.

etc etc etc Until you run out of fragments (you'll get some error when no more exist)

Now that the fragments have been downloaded, you can use this PHP script to combine them into a single .flv file. This file can be played with VLC but still isn’t an optimal file format for archiving purposes. In case that link is dead or has changed to a point where it no longer works, you can also download the php file here (save the txt file and rename it to .php)

Run the script in the same directory as your fragments.

$ php adobe.php 

                            KSV Adobe HDS Downloader

Found 14 fragments                                                             
Joined 14 fragments in 0.90 seconds                                            

FLV files suck, so use avconv to convert the file to .mp4

$ avconv -i Joined.flv -codec copy output.mp4

avconv version 9.16-6:9.16-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Aug 10 2014 18:16:02 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[flv @ 0xf7e1a0] max_analyze_duration reached
Input #0, flv, from 'Joined.flv':
  Duration: 00:02:14.42, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: h264 (Constrained Baseline), yuv420p, 640x360 [PAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc
    Stream #0.1: Audio: aac, 44100 Hz, stereo, fltp
Output #0, mp4, to 'output.mp4':
    encoder         : Lavf54.20.4
    Stream #0.0: Video: libx264, yuv420p, 640x360 [PAR 1:1 DAR 16:9], q=2-31, 1k tbn, 1k tbc
    Stream #0.1: Audio: aac, 44100 Hz, stereo
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press ctrl-c to stop encoding
frame= 4028 fps=  0 q=-1.0 Lsize=   16824kB time=134.37 bitrate=1025.7kbits/s    
video:14682kB audio:2005kB global headers:0kB muxing overhead 0.815393%

All finished; you should be left with a mp4 file around the same size as the original flv file.