API Reference

Generating cool video previews for your users

This tutorial follows our article about How to encode videos. You should read it first if you haven't.

Without a cool thumbnail, a video is not as attractive as it could be, that's why we provide a number of features to make the difference.

Before getting started, let's declare some variables to keep things DRY and easier to maintain. Open your text editor, create a config file coconut.conf:

var s3 = s3://accesskey:secretkey@mybucket/demo
var num = 3 # number of thumbnails we want to generate

Then, we set the source video location:

set source = http://media.s3.amazonaws.com/demo.mp4

Note that you can edit the config file from the previous tutorial if you want.

Static thumbnails

What we are going to do is simple: we will generate 3 small and 3 large thumbnails that will be uploaded to our S3 bucket. Small thumbnail size will be 200px wide and large ones 640px wide.

-> jpg:200x = $s3/thumbnails/small/demo_#num#.jpg, number=$num
-> jpg:640x = $s3/thumbnails/large/demo_#num#.jpg, number=$num

As you notice, we used the #num# specifier in the filenames for the sequence number. In this example, the filenames will become: demo_01.jpg, demo_02.jpg and demo_03.jpg

As we already saw in the first tutorial, we used the convenient variables $s3 and $num to not repeat ourselves and to keep things organized.

Animated GIFs: a must to attract your users

Animated GIFs are so trendy today that it's a big plus to use them to display a preview of a video.

animated GIF

As always, it's really easy, we're doing all the heavy work from generating the GIF to optimizing it for you.

-> gif:300x = $s3/animation.gif

You can have a look at the documentation for more information.

Storyboard: get an insight of the video in one picture

Storyboards are a neat way of getting insights into the video content. By looking at 8 pictures max, your users should have a good idea of what the video is about and whether they would like to watch it or not.


-> storyboard:640x = $s3/storyboard.png

For more information, you can read the full documentation.

Submitting the config file

This is how the config file looks so far:

var s3 = s3://accesskey:secretkey@mybucket/demo
var num = 3 # number of thumbnails we want to generate

set source = http://media.s3.amazonaws.com.mp4

# We suggest you to use our Webhook Inspector https://app.coconut.co/tools/webhooks
# to inspect the POST request we send. Very handy for testing
set webhook = http://yourserver.com/webhook/coconut

-> jpg:200x = $s3/thumbnails/small/demo_#num#.jpg, number=$num
-> jpg:640x = $s3/thumbnails/large/demo_#num#.jpg, number=$num
-> gif:300x = $s3/animation.gif
-> storyboard:640x = $s3/storyboard.png

Here is the curl command to create the job:

curl https://api.coconut.co/v1/job \
-u api-key: \
-T coconut.conf

We provide a number of client libraries to make requests very easily, so be sure to check them out.

That concludes our tutorial about creating attractive and awesome video previews.

Final tutorial, we will show you how to handle webhooks that are triggered when the job is completed