opencoconut / coconutrb

Ruby client Library for encoding Videos with Coconut

Home Page:https://coconut.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coconut Ruby Library

The Coconut Ruby library provides access to the Coconut API for encoding videos, packaging media files into HLS and MPEG-Dash, generating thumbnails and GIF animation.

This library is only compatible with the Coconut API v2.

Documentation

See the full documentation.

Installation

You can install it via rubygems:

gem install coconutrb

Bundler

In Gemfile:

gem 'coconutrb', '~> 3.0.0'

And then, type in your terminal:

bundle install

Usage

The library needs you to set your API key which can be found in your dashboard. Webhook URL and storage settings are optional but are very convenient because you set them only once.

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

Coconut::Job.create(
  input: { url: "https://mysite/path/file.mp4" },
  outputs: {
    "jpg:300x": { path: "/image.jpg" },
    "mp4:1080p": { path: "/1080p.mp4" },
    "httpstream": {
      hls: { path: "hls/" }
    }
  }
)

Getting information about a job

Coconut::Job.retrieve("OolQXaiU86NFki")

Retrieving metadata

Coconut::Metadata.retrieve("OolQXaiU86NFki")

Per-request configuration

cli = Coconut::Client.new(api_key: "k-api-key-prod")
Coconut::Job.create(job, client: cli)

Released under the MIT license.

About

Ruby client Library for encoding Videos with Coconut

https://coconut.co


Languages

Language:Ruby 100.0%