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

Variables

Keyword: variables must be prefixed by the keyword var.

Variables can be used anywhere in the config file with this syntax $varname.

Here is an example:

var s3 = s3://akey:skey@bucket
set source = http://mysite.com/video.avi

-> mp4 = $s3/video.mp4

Built-in variables

These built-in variables are directly usable in the config file:

VariableTypeDescription
$source_mime_typestring
$source_sizeintsize in bytes
$source_formatstring
$source_widthint
$source_heightint
$source_fpsint
$source_video_bitrateintbitrate in kbps
$source_rotationintrotation in degrees. 0 if video is not rotated.
$source_is_hdbooltrue if at least 720p
$source_is_audio_onlybooltrue if audio only
$source_durationintduration in second
$source_video_codecstring
$source_audio_codecstring
$source_channelsint2 for stereo, 1 for mono, 0 for no audio
$source_audio_bitrateintbitrate in kbps
$source_sample_rateintsample rate in Hz

Usage examples

Combined with the if-statement, built-in variables can be very powerful. Let's see some examples:

Transcode the video to HD if the video is at least half HD (720p):

-> mp4:720p = $s3/video_hd.mp4, if=$source_is_hd

Or better, transcode the video to half HD and full HD depending on the original video resolution:

-> mp4:720p  = $s3/video_720p.mp4 , if=$source_width >= 1280
-> mp4:1080p = $s3/video_1080p.mp4, if=$source_width >= 1980

Encode the video if it's only < 10 sec long:

-> mp4 = $s3/video.mp4, if=$source_duration <= 10