Skip to documentation
Deploy on AWS
Menu
Documentation · 19 of 19

Docs/Streaming outputs

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

NameTypeDefaultRequired
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.stringNo
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 noaudioarray(see below)No
playlist_name<br>The filename without extension that will be used for every playlist or manifest names.stringmasterNo
dash<br>Enable packaging into MPEG-Dash.hashNo
path<br>The relative path where the different Dash files will be uploaded.stringYes
hlsfmp4<br>Will also generate HLS fMP4 playlist files.boolNo
hls<br>Enable packaging into HLS (.TS Files).hashNo
path<br>The relative path where the different HLS files will be uploaded.stringYes
segment_duration<br>The segment duration in second. By default 4sec or 5sec depending on the original GOP.int`45`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:256k

Video manipulation

NameTypeDefaultRequired
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.int0No
vflip<br>Vertically Flip the video<br>We automatically use vflip for videos taken upsidedown.boolfalseNo
hflip<br>Horizontally Flip the video<br>We automatically use hflip for videos taken upsidedown.boolfalseNo
duration<br>Max duration in *second* of the video. if 10, the encoded video length will be 10 seconds.intNo
offset<br>Will start the encoding at the given offset in *second*.intNo
watermark<br>Overlay an image (PNG) over the video.hashNo
url<br>URL of the png image that will be incrusted in the video. Transparent and semi-transparent images are compatible.URLNo
position<br>Position of the watermark.<br>topleft topright bottomleft bottomright centerstringtopleftNo

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 ]

NameTypeDefaultRequired
dashhashNo
widevine_pssh<br>Widevine PSSHstringNo
encryption_key<br>Encryption key.<br>Syntax is: KeyIDHex:KeyHexstringNo

Playready (Dash only) [ UNIMPLIMENTED ]

NameTypeDefaultRequired
dashhashNo
playready_laurl<br>The license Acquisition URLURLNo
encryption_key<br>Encryption key.<br>Syntax is: KeyIDHex:KeyHexstringNo

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 ]

NameTypeDefaultRequired
hlshashNo
encryption_mode<br>Must be SAMPLE-AESstringNo
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"stringNo
encryption_key_uri<br>DRM server URIstringNo

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)

NameTypeDefaultRequired
hlshashNo
encryption_mode<br>Must be AES-128stringAES-128No
encryption_key<br>Hexadecimal key to enable AES-128 encryption.stringNo
encryption_key_uri<br>Encryption key URI (may be a relative or absolute URI).stringkey.binNo

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>