Combining Transmuxing to MPEG-DASH with Limit Access Using a Secret Key

To combine mp4 transmuxing to MPEG-DASH with the Limit Access Using a Secret Key feature, you need to:  

  • Activate the “Limit access using secret key ” feature through the Universal CDN Control panel and enter your secret key. 
  • Generate the hash of your resource by including the file path from the URI, the secret key, and the values of the cdn_creation_time, and cdn_ttl
  • Update the file path of URI to your resource after the generation of their cdn_hash by prefixing ‘/dash’ at the beginning and appending ‘/manifest.mpd’ at the end. 


Step by step guidance


1. Generate the cdn_hash of your resource by following the Limit Access Using a Secret Key article. In the example below, the hash value has been generated by using:

  • the secret key entered in the Universal CDN Control Panel
  • URI path (e.g ‘/foo/bar/foobar.mp4’)
  • creation time (current Unix timestamp)
  • Time to live (TTL). Note that the TTL can be set through the Universal CDN Control Panel. If so, it is not necessary to include the TTL parameter in the generation of the cdn_hash value.


Тhe prefix ‘/dash’ and the suffix ‘/manifest.mpd’ have to be excluded when generating hash value. 


2. Prefix the URI path with ‘/dash’ and append ‘/manifest.mpd’ at the end (e.g. ‘/dash/foo/bar/foobar.mp4/manifest.mpd’). 


3. Compose the full URL. The transmuxing to MPEG-DASH requires, after the generation of the cdn_hash, the URI of your MP4 resources to be composed by the pattern shown in the example below:

http(s)://bar.foobar.bar/dash/foo/bar/foobar.mp4/manifest.mpd?cdn_hash=63c21767af6896fd305f08f8e9c5d5fb&cdn_creation_time=1615987169


The following script was used to generate the full URL to the file with transmuxing to HLS and by Limit access using a secret key.

<?php
$secret_key = '<your secret key>';

/* URI Path to your mp4 file */
$request_path = '/foo/bar/foobar.mp4';

/* Current Unix timestamp */
$cdn_creation_time = time(); 

/* For how long the generated URL will be active (in seconds) */
$cdn_ttl = 86400;  

/* Generate the cdn_hash as md5 sum */
$hash = md5($request_path . $secret_key . $cdn_creation_time . $cdn_ttl);

/* Generating the URL with a secret key by concatenating domain, path, and parameters */
$access_url  = 'https://bar.foobar.bar' . '/dash' . $request_path.'/manifest.mpd'
                         .'?cdn_hash=' . $hash 
                         .'&cdn_creation_time=' . $cdn_creation_time
                         .'&cdn_ttl=' . $cdn_ttl;

echo $access_url . "\n";
?>

The output of the script is the same as the pattern shown above.


Setting up the ‘/bsd’ and ‘/sd’ parameters with Limit Access Using a Secret Key


The same logic applies when including the/bsd and /sdparameters. 

http(s)://bar.foobar.bar/dash/bsd/10000-10000-15000/sd/20000/foo/bar/foobar.mp4/manifest.mpd?cdn_hash=63c21767af6896fd305f08f8e9c5d5fb&cdn_creation_time=1615987169

Both parameters ‘/bsd and ‘/sd’ along with their values are part of the URI path (e.g. /bsd/10000-10000-15000/sd/20000/foo/bar/foobar.mp4) and should be included when generating hash value as well. 


URLSET with Limit Access Using a Secret Key


The same logic applies again to build a playlist from multiple files but this time you need to append ‘/urlset/manifest.mpd’ instead of ‘/manifest.mpd at the end of the path of the file as shown in the example below:  

http(s)://bar.foobar.bar/dash/foo/bar/foobar_,24,36,48,0p.mp4/urlset/manifest.mpd?cdn_hash=63c21767af6896fd305f08f8e9c5d5fb&cdn_creation_time=1615987169

The playlist parameters  24,36,48,0p are part of the URI path and should be included in the generation of the cdn_hash value as well.



Video Streaming Services

Delivering HLS Content

Combining Transmuxing to HLS with Limit Access Using a Secret Key

Speeding Up the HLS Delivery

Delivering MPEG-DASH Content