Skip to content
p-u-m-a edited this page Jan 28, 2016 · 35 revisions

AdobeHDS is a PHP script to join HDS fragments into flv file. You can either use manifest switch or use any download manager with batch capabilities to download the fragments although use of manifest switch is recommended.

php AdobeHDS.php --manifest "your_manifest_url" --delete

Offline fragment processing

If you fragments are serially numbered without a base filename (1.f4f, 2.f4f, … 99.f4f) then you can run the script without any parameter, and it will look for the fragments in current directory and output will be saved as Joined.flv.

However if your fragments are named with base filename (MyVideo-Seg1-Frag1.f4f, MyVideo-Seg1-Frag2.f4f, … MyVideo-Seg1-Frag99.f4f) then you can pass the base filename with fragments switch to the script and it will look for the fragments starting with this name, and output will be saved as MyVideo-Seg1-Frag.flv. f4f extension is optional.

1.f4f, 2.f4f, … 99.f4f

php AdobeHDS.php

MyVideo-Seg1-Frag1.f4f, MyVideo-Seg1-Frag2.f4f, … MyVideo-Seg1-Frag99.f4f

php AdobeHDS.php --fragments MyVideo-Seg1-Frag

or

php AdobeHDS.php MyVideo-Seg1-Frag

Usage

You can use the script with following options:

--help              displays this help
--debug             show debug output
--delete            delete fragments after processing
--fproxy            force proxy for downloading of fragments
--play              dump stream to stdout for piping to media player
--rename            rename fragments sequentially before processing
--update            update the script to current git version
--adkey     [param] akamai session decryption key
--auth      [param] authentication string for fragment requests
--duration  [param] stop recording after specified number of seconds
--filesize  [param] split output file in chunks of specified size (MB)
--fragments [param] base filename for fragments
--fixwindow [param] timestamp gap between frames to consider as timeshift
--manifest  [param] manifest file for downloading of fragments
--maxspeed  [param] maximum bandwidth consumption (KB) for fragment downloading
--outdir    [param] destination folder for output file
--outfile   [param] filename to use for output file
--parallel  [param] number of fragments to download simultaneously
--proxy     [param] proxy for downloading of manifest
--quality   [param] selected quality level (low|medium|high) or exact bitrate
--referrer  [param] Referer to use for emulation of browser requests
--start     [param] start from specified fragment
--useragent [param] User-Agent to use for emulation of browser requests

Proper switch usage

1. Grabbing the manifest and auth parameter with Firefox
HDS Link Detector Add-on

I have also written a pretty basic [Firefox add-on] (https://addons.mozilla.org/addon/hds-link-detector/) to auto-detect HDS links and generate proper command line which you can simply paste in command prompt. Whenever a link is detected it shows a notification which remains visible for few seconds. Clicking on this notification will copy the generated command line to clipboard. I have tested it with pluzz.fr, fora.tv, nrk.no and few other sites and it seems to work pretty well. Though I have no intention to work on it any further it still serves as a good cross-platform helper tool to easily grab HDS videos. Installed add-on will show up in add-on bar (Ctrl + /). Clicking the add-on icon will enable or disable the link detection.

Manual method

Press Ctrl+Shift+K to open the built-in web console. Type .f4m in search filter to grab the manifest URL.

http://some.website.com/video/manifest.f4m?foobar

To grab auth parameter use Seg as search filter and copy only the request parameters.

http://some.website.com/video/Seg1-Frag1?foobar

here foobar can be passed to auth switch.

2. Play

You can use the play switch to directly pipe the script output to video player of your choice.

  • php AdobeHDS.php --manifest "manifest_url" --play | mplayer -cache 2048 -
  • php AdobeHDS.php --manifest "manifest_url" --play | vlc --file-caching=10000 -
3. Proxy

You can pass the proxy parameter in any of the following formats:

  • http://1.2.3.4:1234 or 1.2.3.4:1234
  • socks4://1.2.3.4:1234
  • socks5://1.2.3.4:1234

By default proxy is only used for downloading of manifest but you can use fproxy switch to force the downloading of fragments through proxy.

4. User-Agent

useragent switch is normally used along with auth parameter. You must use the User-Agent string of the same browser from which you have copied the auth string.

Installing PHP for dummies (Windows only)

  1. Download PHP 5.4 zip package and extract it to C:\PHP folder.

  2. Download PHP.ini and copy it to the same folder.

  3. Right click on "My Computer" and go to Properties->Advanced->Environment Variables and add following string to the end of Path Variable.

;C:\PHP
  1. Open cmd prompt and type php -v. If you have done above steps correctly then you will see something like following.
PHP 5.4.37 (cli) (built: Jan 21 2015 01:59:37)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Troubleshooting

1. manifest is not downloaded

Error message displayed by AdobeHDS:

Access Denied! Unable to download the manifest.

This most probably means that the manifest authentication token is expired by the time you are trying to use it. Some websites use extremely short-lived authentication tokens, 10 seconds or even less. Try to copy/paste the manifest URL faster.

2. manifest downloads successfully, but fragments do not

Error message displayed by AdobeHDS:

Access Denied! Unable to download fragments.

Look at the --auth switch, under Manual method above. You need to copy/paste the query string from any fragment download in your browser, i.e. the part of the URL after the ?. Example --auth value:

pvtoken=exp%3D9999999999%7Eacl%3D%252f%252a%7Edata%3DZXhwPTE0NTM0NTAzNzJ+YWNsPSUyZip+ZGF0YT1wdmMsc35obWFjPTViZDg0YjlkNjNjMjg4YjFmZGI1NWRhNzlhMzI0ZmVhMzVlM2Q0ZmYyYWE0YjA4NzVlYjExMjYwZmE0NDM1MmU%3D%21uPh3SVIi1cGo1lU6lZ/Yb9uPMdM1NDxHuH/x0rp58As%3D%7Ehmac%3D2F86C6E2D72ACA17C75A41DC30083C4930414BE27C47B16D5412F6BA55A2C0AA