NodeJS client library

Installation

To install this package:

npm install coconutjs

Usage

First, we will setup the notification and storage settings:

const Coconut = require('coconutjs')
const coconut = new Coconut.Client('k-api-key')

coconut.notification = {
  'type': 'http',
  'url': 'https://yoursite/api/coconut/webhook'
}

coconut.storage = {
  'service': 's3',
  'bucket': 'my-bucket',
  'region': 'us-east-1',
  'credentials': {
  	'access_key_id': 'access-key',
    'secret_access_key': 'secret-key'
   }
}

By default, the region is us-east-1, however if you want to use our EU region:

coconut.region = "eu-west-1"

Creating a job

Creating complexe job is easy. In this example, we create 2 webp, 1 mp4 video and HLS outputs.

const job = await coconut.Job.create({
  'input': { 'url': 'https://mysite/path/file.mp4' },
  'outputs': {
  	'webp': [
      {
        'key': 'webp:cover',
        'path': '/cover_%05d.webp',
        'number': 10,
        'format': {
          'resolution': '600x'
        }
      },
      {
        'key': 'webp:thumbs',
        'path': '/thumbs_%05d.webp',
        'interval': 10,
        'format': {
          'resolution': '200x'
        },
        'sprite': {
          'limit': 100,
          'columns': 10
        },
        'vtt': {
        	'filename': 'thumbs.vtt'
         }
      },
    ],
    'mp4': [
      {
        'key': 'mp4',
      	'path': '/video.mp4',
        'format': {
          'quality': 4
        }
      }
     ],
     'httpstream': {
       'hls': { 'path': 'hls/' }
      }
   }
})

console.log(job)