Ruby client library

Installation

To install this package:

gem install coconutrb

Bundler

In Gemfile:

gem 'coconutrb', '~> 3.0.0'

And then, type in your terminal:

bundle install

Usage

First, we will setup the notification and storage settings:

Coconut.api_key = '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"
  }
}

Creating a job

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

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/' }
      }
   }
})