API documentation

Coconut's API is a config-based API built with simplicity and flexibility in mind.
Encode your first video in less than 5 minutes.

API Reference

HTTP Stream packager

Available since 2017-09-31

Keyword: outputs must be prefixed by the keyword -> followed by the format ID.

Format ID: httpstream

The first value is the output URL without filename.

Packaging into MPEG-Dash and HLS:

var s3 = s3://accesskey:secretkey@bucket

-> httpstream = $s3, dash=/dash, hls=/hls, playlist_name=master

Packaging into HLS fMP4 as well. Will use the same fragmented MP4 files than MPEG-Dash.

-> httpstream = $s3, dash+hlsfmp4=/dash, playlist_name=master

AES encryption for HLS (TS files):

-> httpstream = $s3, hls=/, playlist_name=master, hls_encryption_key=ba66aa7334ba85b3bc093db1db3ab931, hls_encryption_key_uri=http://yoursite.com/hls/aes/key.bin

Parameters

NameTypeDefaultRequired
if
If the given condition is false, the output won't be processed.
Logical operators we support are: < > <= >= <> != = AND OR NOT..
string No
variants
A list of Simple Formats separated by commas
The formats specs:
• container must be mp4
• Video codec must be either h264, hevc or novideo
• Audio codec must be either aac or noaudio
format ID[,] mp4:x:64k,
mp4:x,
mp4:240p_400k:x,
mp4:360p_600k:x,
mp4:360p_1000k:x,
mp4:480p_1500k:x,
mp4:720p:x
mp4:1080p:x
No
playlist_name
The filename without extension that will be used for every playlist or manifest names.
string master No
dash
Enable packaging into MPEG-Dash. Value is the relative path where the different files will be uploaded.
string No
dash+hlsfmp4
Enable packaging into MPEG-Dash and HLS fMP4 (Fragmented MP4 Files). Value is the relative path where the different files will be uploaded.
string No
hls
Enable packaging into HLS (.TS Files). Value is the relative path where the different files will be uploaded.
string No
hls_encryption_key
HLS packaging only: Hexadecimal key to enable AES-128 encryption.
string No
hls_encryption_key_uri
HLS packaging only: Encryption key URI (may be a realtive or absolute URI).
string key.bin No

Variants

It is important that you separate the video from the audio track to be compliant with the DASH-if guidelines.

To use a video only format, name it like this mp4:720p:x. For an audio only format: mp4:x:64k.

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>