HLS and MPEG-Dash
Every outputs must be set inside the outputs key with each value being a Hash describing the output format and settings.
Examples
Packaging into MPEG-Dash and HLS:
{
"outputs": {
"httpstream": {
"hls": {
"path": "/hls"
},
"dash": {
"path": "/dash"
}
}
}
}Customizing the variants:
{
"outputs": {
"httpstream": {
"hls": {
"path": "/hls"
},
"dash": {
"path": "/dash"
},
"variants": [
"mp4:x:64k",
"mp4:240p::quality=2",
"mp4:480p::quality=3,maxrate=1500k",
"mp4:720p::quality=4,maxrate=3000k"
]
}
}
}Packaging into MPEG-Dash and HLS fMP4:
{
"outputs": {
"httpstream": {
"dash": {
"path": "/dash",
"hlsfmp4": true
}
}
}
}Parameters
HLS & MPEG-Dash options
| Name | Type | Default | Required | |
|---|---|---|---|---|
| path<br>The path where the files will be uploaded. See Storage. | string | / | No | |
| key<br>Will rename the output key which is sent in the notification payload. Very useful because you can change the output settings but the key name you get at the end will be unchanged. No code to update on your side. | string | No | ||
variants<br>A list of formats<br>The formats specs:<br>• container must be mp4 or mp3<br>• Video codec must be either h264 (default), hevc, novideo<br>• Audio codec must be either aac or noaudio | array | (see below) | No | |
| playlist_name<br>The filename without extension that will be used for every playlist or manifest names. | string | master | No | |
| dash<br>Enable packaging into MPEG-Dash. | hash | No | ||
| ↳ path<br>The relative path where the different Dash files will be uploaded. | string | Yes | ||
| ↳ hlsfmp4<br>Will also generate HLS fMP4 playlist files. | bool | No | ||
| hls<br>Enable packaging into HLS (.TS Files). | hash | No | ||
| ↳ path<br>The relative path where the different HLS files will be uploaded. | string | Yes | ||
| segment_duration<br>The segment duration in second. By default 4sec or 5sec depending on the original GOP. | int | `4 | 5` | No |
Sample variants:
mp4:x:64k
mp4:240p::quality=4,maxrate=400k
mp4:360p::quality=4,maxrate=1000k
mp4:480p::quality=4,maxrate=1500K
mp4:720p::quality=4,maxrate=2000k
mp4:1080p::quality=4,maxrate=4000k
mp4:2160p::quality=4,maxrate=8000k
// Audio only hls
mp3:64k
mp3:128k
mp3:256kVideo manipulation
| Name | Type | Default | Required |
|---|---|---|---|
transpose<br>Rotate the video<br>0 90CounterCLockwise and Vertical Flip (default)<br>1 90Clockwise<br>2 90CounterClockwise<br>3 90Clockwise and Vertical Flip<br>We automatically use transpose for videos taken in portrait mode. | int | 0 | No |
| vflip<br>Vertically Flip the video<br>We automatically use vflip for videos taken upsidedown. | bool | false | No |
| hflip<br>Horizontally Flip the video<br>We automatically use hflip for videos taken upsidedown. | bool | false | No |
duration<br>Max duration in *second* of the video. if 10, the encoded video length will be 10 seconds. | int | No | |
| offset<br>Will start the encoding at the given offset in *second*. | int | No | |
| watermark<br>Overlay an image (PNG) over the video. | hash | No | |
| ↳ url<br>URL of the png image that will be incrusted in the video. Transparent and semi-transparent images are compatible. | URL | No | |
↳ position<br>Position of the watermark.<br>topleft topright bottomleft bottomright center | string | topleft | No |
Add a watermark and cut the output at 2min:
{
"outputs": {
"httpstream": {
"dash": {
"path": "/dash",
"hlsfmp4": true
},
"duration": 120,
"watermark": {
"url": "https://host/coconut/watermark.png",
"position": "center"
}
}
}
}DRM and Encryption
Widevine (Dash only) [ UNIMPLIMENTED ]
| Name | Type | Default | Required |
|---|---|---|---|
| dash | hash | No | |
| ↳ widevine_pssh<br>Widevine PSSH | string | No | |
↳ encryption_key<br>Encryption key.<br>Syntax is: KeyIDHex:KeyHex | string | No |
Playready (Dash only) [ UNIMPLIMENTED ]
| Name | Type | Default | Required |
|---|---|---|---|
| dash | hash | No | |
| ↳ playready_laurl<br>The license Acquisition URL | URL | No | |
↳ encryption_key<br>Encryption key.<br>Syntax is: KeyIDHex:KeyHex | string | No |
Widevine and Playready example:
{
"outputs": {
"httpstream": {
"dash": {
"path": "/dash",
"widevine_pssh": "htb3ZpZVjRG9ubDQHRhPY2NaE65qWBi3cQQs2yGgLI0iZNUjSIQ0gkxEh7mH9WEj3JWbBg==",
"playready_laurl": "https://playready.ezdrm.com/cency/preauth.aspx?pX=ECD463",
"encryption_key": "d21875b042cddb98018d7f6b7718ddb2:be02128f059b70c9e6a2e9d02ae64e14"
}
}
}
}Fairplay (HLS only) [ UNIMPLIMENTED ]
| Name | Type | Default | Required |
|---|---|---|---|
| hls | hash | No | |
↳ encryption_mode<br>Must be SAMPLE-AES | string | No | |
| ↳ encryption_key<br>DRM Encryption Key. With FairPlay, the key and IV are delivered together. The first 32 characters are used in the key file for "key" and the last 32 characters are used for "iv" | string | No | |
| ↳ encryption_key_uri<br>DRM server URI | string | No |
Fairplay example:
{
"outputs": {
"httpstream": {
"hls": {
"path": "/hls",
"encryption_mode": "SAMPLE-AES",
"encryption_key": "d013b7710d187bd8d8d6987f5b42cdb2be260ec912d4e9f020e68e59b7a2a014",
"encryption_key_uri": "skd://fps.ezdrm.com/;1XXXXXX0-c7ed-4XXX-b15c-XXXXXXXXXa25"
}
}
}
}Simple HTTP Key Delivery (HLS only)
| Name | Type | Default | Required |
|---|---|---|---|
| hls | hash | No | |
↳ encryption_mode<br>Must be AES-128 | string | AES-128 | No |
| ↳ encryption_key<br>Hexadecimal key to enable AES-128 encryption. | string | No | |
| ↳ encryption_key_uri<br>Encryption key URI (may be a relative or absolute URI). | string | key.bin | No |
AES Encryption example:
{
"outputs": {
"httpstream": {
"hls": {
"path": "/hls",
"encryption_mode": "AES-128",
"encryption_key": "ba66aa7334ba85b3bc093db1db3ab931",
"encryption_key_uri": "http://yoursite.com/hls/aes/key.bin"
}
}
}
}Cross-Origin Resource Sharing (CORS)
You will need to setup the CORS headers if the playlist and mp4 files are hosted on a different domain, which is most likely the case. Here are the different headers you need to setup:
Access-Control-Allow-Headers: "origin, range"Access-Control-Allow-Methods: "GET, HEAD, OPTIONS"Access-Control-Allow-Origin: "*"Access-Control-Expose-Headers: "Server,range"
If your files are hosted on Amazon S3, the CORS policy should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>