NAV

General

What’s new in Telestream Cloud?

Recent changes (July)

Major changes (June)

Major changes from May

Major changes from April

Getting started with Telestream Cloud

At the core of Telestream Cloud is a REST API which supports uploading and managing of videos, encodings and output profiles.

Every Telestream Cloud account has a number of Factories. Each Factory defines a single storage for your uploaded videos, resulting encodings and thumbnails. It also contains list of profiles that your content will be encoded to.

Typically you will want to create a separate Factory for each website you plan to integrate Telestream Cloud into. You can also use Factories to separate production and staging environments.

To access the API there are client libraries available in many languages: See all client libraries. Refer to the API Docs when using the API. All API responses are JSON-formatted.

Javascript Uploader

Telestream Cloud provides two ways of sending video files in for transcoding. The first is by using the url of a video anywhere on the web (see API Docs for details). The other method is by using our excellent Javascript uploader which supports seamless HTML5 and Flash uploads, automatically detected depending on the client’s browser.

To configure the encoding output formats, refer to the Encoding Presets documentation.

Feedback

Whether you feel that this article is incorrect, outdated or missing information, don’t hesitate to contact the support.

Libraries

Client Libraries

Officially supported libraries

Sample applications

Coming soon!

API

This is documentation for new version of Telestream Cloud API. It introduces number of changes and updates that may affect your integration.

We still maintain documentation for API V2 and you will still be able to use it.

What’s new in V3?

We have replaced cloud field with factory.

There are new API endpoints:

Updates to profiles API:

Client initialization

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from telestream_cloud import TelestreamCloud

#initialize
tc = TelestreamCloud(
        access_key='your-access-key',
        secret_key='your-secret-key',
        api_host='api.cloud.telestream.net',
        api_port='443',
        factory_id='your-factory-id')

# select resource
flip = tc.get_resource('flip')
#!/usr/bin/env ruby
# encoding: UTF-8

require 'telestream_cloud'
require 'pp'

TelestreamCloud.configure do
  api_host "api.cloud.telestream.net"
  api_port "443"
  factory_id "2297c22da25dd3ce3ea64513eda642be"
  access_key "80a91c7b8d1adeaf25b1"
  secret_key "c92dbf4065badf0ca9c4"
end

flip = TelestreamCloud.resources(:flip)
package main

import (
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  fp := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), nil)
  _ = fp
}

A successful communication with Telestream Cloud requires a set of credentials. Required parameters are:

Optional parameters:

The access_key and secret_key used to authenticate the request are provided when you sign up for your Telestream Cloud account. Your keys can always be found by logging in to your account by visiting cloud.telestream.net. After logging in you can browse your Factories and find out their unique indetificators, factory_id-s.

An api_host is one of three API end-points:

You’d usually want to have 443 as a value of api_port, to indicate that you want to connect using SSH authentication protocol, but it’s also possible to connect to Telestream Cloud using basic HTTP and port 80.

When you’re done initializing the client, you can now choose which resource you want to use. Currently available resources are:

API authentication

Example request

from pprint import pprint

pprint(tc.signed_params('GET', '/videos.json', {'some_params': 'some_value'}))
require 'pp'

PP.pp(TelestreamCloud.signed_params('GET', '/videos.json', {'some_params' => 'some_value'}))
package main

import (
  "fmt"
  "log"
  "net/url"

  "github.com/Telestream/telestream-cloud-go-sdk/client"
)

func main() {
  cl := &client.Client{
    Host: "host",
    Options: &client.Options{
      AccessKey: "access_key",
      SecretKey: "secret_key",
      Namespace: "v3.0",
    },
  }
  params := make(url.Values)
  if err := cl.SignParams("GET", "/path.json", params); err != nil {
    log.Fatal(err)
  }
  fmt.Println(params)
}

Example response

{'access_key': '80a91c7b8d1adeaf25b1',
 'factory_id': '2297c22da25dd3ce3ea64513eda642be',
 'signature': 'y9cMGDkUNLtucS/fKa7EISvGeThot6h2sLgJKq9jkEg=',
 'some_params': 'some_value',
 'timestamp': '2015-04-29T13:06:36.594402+00:00'}
{"some_params"=>"some_value",
 "factory_id"=>"2297c22da25dd3ce3ea64513eda642be",
 "access_key"=>"80a91c7b8d1adeaf25b1",
 "timestamp"=>"2015-04-29T13:15:56.453740Z",
 "signature"=>"Vv4wsNVF038GRn/ON21v+tbYJ3/WY6r8L3rt92gX5qY="}
params = url.Values{
  "access_key": {"d24f44a7cee7c47c9f66"},
  "factory_id":   {"3037dff38de0b77c641f2243bbdafe87"},
  "timestamp":  {"2015-06-08T14:01:20.862018914Z"},
  "signature":  {"a6aLsyXwlyvOOVtn3wISqdc2LR+orXrNC9RVmQ4qpBw="},
}

All Telestream Cloud API requests must be signed to ensure they are valid and authenticated. For GET and DELETE requests the additional parameters must be url encoded and added to the parameters in the url. When making a POST or PUT request they should be included in the usual parameters payload submitted.

A correctly signed request contains the following additional parameters:

parameters attributes
access_key Provided when you sign up for Telestream Cloud
factory_id Provided when you sign up for Telestream Cloud
timestamp Current UTC time in iso8601 format
signature HMAC signature generated as described below

You usually don’t have to worry about it, since building a valid signature is done transparently by the client libraries. These libraries also provide methods that allows you to generate valid sets of values for provided parameters.

Building the signature

Instead of relying on libraries capabilities to generate valid signatures for Telestream Cloud requests you can easily generate one yourself using basic cryptographic functions. This is useful for example if you’re planning to write and use your own version of communication library using your favorite programming language.

The signature is generated using the following method:

  1. Create a canonical_querystring by url encoding all of the parameters and the values, and joining them into one string using the = character to separate keys and their values, and the & character to separate the key value pairs.

    All parameters and values have to be joined in the alphabetical order.

    Make sure it encodes the given string according to » RFC 3986. (spaces are escaped using %20 and not a +)

    A typical canonical_querystring might look as follows: access_key=85f8dbe6-b998-11de-82e1-001ec2b5c0e1&factory_id=bd54547d152e91104d82c0a81e7d5ff2&timestamp=2009-10-15T15%3A38%3A42%2B01%3A00 … other parameters such as those in the POST request would also be added to this string.

  2. Construct the string_to_sign by concatenating the uppercase HTTP request method (GET, POST, PUT or DELETE), hostname (api-us-east.cloud.telestream.net or api-eu-west.cloud.telestream.net), request uri (e.g. /videos.json) and canonical_querystring with newlines (\n).

    The api version /v3.0 should not be part of the request uri

  3. To generate the signature, first HMAC SHA256 encode the complete string_to_sign using your secret_key as the key. For example, using Ruby: hmac = HMAC::SHA256.new(secret_key) then hmac.update(string_to_sign)

  4. Then take the binary digest of the hmac output and base 64 encode it. Make sure to remove any newline characters at the end. In Ruby you would do Base64.encode64(hmac.digest).chomp

  5. The signature could be rejected by the server for the following reasons:

request condition
POST The signature has already been used
POST /videos.json The timestamp is expired for 30 minutes
not POST The timestamp is expired for 5 minutes

Working example

Firstly, we prepare all the credentials we’ll need.

#!/usr/bin/env bash

api_host="api-eu-west.cloud.telestream.net"
api_port="443"
factory_id="2297c22da25dd3ce3ea64513eda642be"
access_key="80a91c7b8d1adeaf25b1"
secret_key="c92dbf4065badf0ca9c4"
timestamp=$(date -u +"%Y-%m-%dT%H%%3A%M%%3A%S.")
printf "timestamp: ${timestamp}\n" 
# 2015-04-30T140X0P+0100X0P+003.

We generate timestamp expressed according to ISO 8601. A colon character must be encoded as a %3A.

some_params='some_params=some_value'

canonical_querystring="access_key=${access_key}&factory_id=${factory_id}&${some_params}&timestamp=${timestamp}"
printf "canonical_querystring: ${canonical_querystring}\n"
# canonical_querystring: access_key=70a91c7b8d1adeaf25b1&factory_id=1297c22da25dd3ce3ea64513eda642be&some_params=some_value&timestamp=2015-04-30T140X0P+0100X0P+003. 

We construct properly encoded canonical_querystring. All parameters have a key=value format, are listed in alphabetical order and are separated by an ampersand character (&)

string_to_sign="GET\n${api_host}\n/videos.json\n${canonical_querystring}"
printf "string_to_sign:\n${string_to_sign}\n"
# string_to_sign:
#GET
#api-eu-west.cloud.telestream.net
#/videos.json
#access_key=70a91c7b8d1adeaf25b1&factory_id=1297c22da25dd3ce3ea64513eda642be&some_params=some_value&timestamp=2015-04-30T140X0P+0100X0P+003.

We first construct string_to_sign by providing HTTP request method, route path and canonical_querystring.

signature=$(printf "${string_to_sign//%/%%}" | openssl dgst -sha256 -binary -hmac "${secret_key}" | sed 's/^.* //' | base64)
printf "signature: ${signature}\n"
# signature: RFyXe4ZiRVRZ3yhztlX8v9s6Oo3Z2amfRxL3CH0NNDc= 

The signature is generated by signing that string using HMAC SHA256 and then by encoding its binary output with base 64.

url="https://${api_host}:${api_port}/v3.0/videos.json?${canonical_querystring}&signature=${signature//+/%2B}"
print "url: ${url}\n"
# url: https://api-eu-west.cloud.telestream.net:443/v2/videos.json?access_key=70a91c7b8d1adeaf25b1&factory_id=1297c22da25dd3ce3ea64513eda642be&some_params=some_value&timestamp=2015-04-30T140X0P+0100X0P+003.&signature=RFyXe4ZiRVRZ3yhztlX8v9s6Oo3Z2amfRxL3CH0NNDc=

curl "${url}" | python -m json.tool
#  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#                                 Dload  Upload   Total   Spent    Left  Speed
#100  3954  100  3954    0     0   4949      0 --:--:-- --:--:-- --:--:-- 22089
#[
#    {
#        "audio_bitrate": 112, 
#        "audio_channels": 2, 
#        "audio_codec": "aac", 
#        "audio_sample_rate": 44100, 
#        "created_at": "2015/04/22 15:08:21 +0000", 
#        "duration": 14014, 
#        "extname": ".mp4", 
#        "file_size": 805301, 
#        "fps": 29.97, 
#        "height": 240, 
#        "id": "cf0161501c17cdc793128c4559f6e57f", 
#        "mime_type": "video/mp4", 
#        "original_filename": "panda.mp4", 
#        "path": "cf0161501c17cdc793128c4559f6e57f", 
#        "source_url": null, 
#        "status": "success", 
#        "updated_at": "2015/04/22 15:08:50 +0000", 
#        "video_bitrate": 344, 
#        "video_codec": "h264", 
#        "width": 300
#    }
#]

We create a full request which is send using curl command line.

Things to look into if you’re having signature issues

Factories

Example request

require 'json'

# Simple API
factories = flip.factories.all()
factories.each { |fac|
    puts(JSON.pretty_generate(fac.attributes))
}

# REST API
factories = TelestreamCloud.get("/factories.json")
puts(JSON.pretty_generate(factories))
# Simple API
factories = flip.factories.all()
for factory in factories:
    print(factory.details)

# REST API
import json
factories_response = tc.get('/factories.json')
print(factories_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  fp := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), nil)
  factories, err := fp.Factories()
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(factories)
}

Example response

{
  "s3_videos_bucket": "mariusz-bucket",
  "id": "e6ff0ed4b7880bfc1ad075963cce2db8",
  "name": "GCS",
  "server_side_encryption": false,
  "url": "https://storage.googleapis.com/satap-bucket/",
  "created_at": "2014/11/05 14:51:14 +0000",
  "s3_private_access": false,
  "updated_at": "2014/11/05 14:51:14 +0000"
}

GET /factories.json

Returns a collection of Factory objects.

Example request

require 'json'

# Simple API
factory = flip.factories.find("477bd69174c4d2b99d9ada70c0dad059")
puts(JSON.pretty_generate(factory.attributes))

# REST API
factory = TelestreamCloud.get("/factories/477bd69174c4d2b99d9ada70c0dad059.json")
puts(JSON.pretty_generate(factory))
# Simple API
factory = flip.factories.find("477bd69174c4d2b99d9ada70c0dad059")
print(factory.details)

# REST API
import json
factory_response = tc.get('/factories/477bd69174c4d2b99d9ada70c0dad059.json')
print(factory_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  fp := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"), nil)
  factory, err := fp.Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(factory)
}

Example response

{
  "id": "e122090f4e506ae9ee266c3eb78a8b67",
  "name": "my_first_factory",
  "s3_videos_bucket": "my-example-bucket",
  "s3_private_access":false,
  "server_side_encryption": false,
  "url": "http://my-example-bucket.s3.amazonaws.com/",
  "created_at": "2010/03/18 12:56:04 +0000",
  "updated_at": "2010/03/18 12:59:06 +0000"
}

GET /factories/:id.json

Returns a Factory object.

Required Parameters

parameters attributes
id ID of the Factory object.

Example request

require 'json'

# Simple API
factory = flip.factories.find("1297c22da25ddda2bea64513eda642be")
factory.name = "test"
factory.outputs_path_format = ":original_:profile"
factory.save()
puts(JSON.pretty_generate(factory.attributes))

# REST API
factory = TelestreamCloud.put("/factories/1297c22da25ddda2bea64513eda642be.json", {
    :name => "test",
    :outputs_path_format => ":original_:profile"
})
puts(JSON.pretty_generate(factory))

# Simple API
factory = flip.factories.find("1297c22da25dd3ce3ea64513eda642be")
factory.name = "test"
factory.outputs_path_format = ":original_:profile"
factory = factory.save()
print(factory.details)

# REST API
import json
factory_response = tc.put("/factories/1297c22da25dd3ce3ea64513eda642be.json", {
    "name": "test"
    "outputs_path_format": ":original_:profile"
})
print(factory_response.json())

Example response

{
  "id": "e122090f4e506ae9ee266c3eb78a8b67",
  "name": "test",
  "s3_videos_bucket": "my-example-bucket",
  "s3_private_access": false,
  "server_side_encryption": false,
  "created_at":"2010/03/18 12:56:04 +0000",
  "url": "http://my-example-bucket.s3.amazonaws.com/",
  "updated_at":"2010/03/18 12:59:06 +0000",
  "outputs_path_format": ":original_:profile"
}

PUT /factories/:id.json

Edits factory settings. Returns Factory object.

Required parameters

parameters attributes
id ID of the Factory object.

Optional parameters

parameters attributes
name Name of the Factory.
s3_videos_bucket Name of your S3 bucket.
s3_private_access Specify if your files are public or private (private files need authorization url to access). Default is false.
aws_access_key AWS access key.
aws_secret_key AWS secret key.
priority Value between 2 and 200 to prioritize jobs on your account. Factory with lower number is first in processing queue. Default is 99`.
server_side_encryption Specify if you want to use multi-factor server-side 256-bit AES-256 data encryption with Amazon S3-managed encryption keys (SSE-S3). Each object is encrypted using a unique key which as an additional safeguard is encrypted itself with a master key that S3 regularly rotates. Default is false.
outputs_path_format Specify the directory where the output files should be stored. By default it is not set.

outputs_path_format

The following keywords can be combined to create outputs path format:

parameters attributes
id ID of the encoding.
video_id ID of the video.
original Original filename of the uploaded video.
date Date the video was uploaded (2009-10-09).
profile Profile name used by the encoding.
type Video type, original or encodings.
resolution Resolution of the video or the encoding (480x340).

By default outputs_path_format is not set.

Also, please note that path_format set for video object has got higher precedence than outputs_path_format set for factory. If you want to use outputs_path_format, you should not send any specific path_format on creating a video object.

Videos

Video is a RESTful resource representing the original media. It describes all major metadata of a media file, it’s size and it’s original filename. It contains a status attribute representing the uploading process of media to S3. status is set to success when the media has been successfully uploaded to S3. Careful: It does not mean that it’s encodings have been encoded.

Example request

require 'json'

# Simple API
videos = factory.videos.all
videos.each { |vid|
    puts(JSON.pretty_generate(vid.attributes))
}

# REST API
videos = TelestreamCloud.get("/videos.json")
puts(JSON.pretty_generate(videos))
# Simple API
videos = factory.videos.all()
for video in videos:
    print(video.details)

# REST API
import json
videos_response = tc.get('/videos.json')
print(videos_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  videos, err := factory.Videos(&flip.VideoRequest{
    Page:    1,
    PerPage: 100,
  })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(videos)
}

Example response

{
  "id": "04b73c8cfc9da71f8f404a2cd5463402",
  "status": "success",
  "created_at": "2016/03/09 13:49:40 +0000",
  "updated_at": "2016/03/09 13:49:47 +0000",
  "mime_type": "video/mp4",
  "original_filename": "panda.mp4",
  "source_url": null,
  "duration": 14014,
  "height": 240,
  "width": 300,
  "extname": ".mp4",
  "file_size": 805301,
  "video_bitrate": 344,
  "audio_bitrate": 112,
  "audio_codec": "aac",
  "video_codec": "h264",
  "fps": 29.97,
  "audio_channels": 2,
  "audio_sample_rate": 44100,
  "path": "eefdf44c1cba7fe6251bcdb48f0ef7b3/04b73c8cfc9da71f8f404a2cd5463402",
  "encodings_count": 1,
  "failed_encodings_count": 0
}

GET /videos.json

Returns a collection of Video objects.

Optional parameters

parameters attributes
status One of success, fail, processing. Filter by status.
page Default is 1.
per_page Default is 100.

GET /videos/:id.json

Example request

# Simple API
video = factory.videos.find("472cd69174c4d2b99d9ada70c0dad059")
print(video.details)

# REST API
import json
video = tc.get('/videos/472cd69174c4d2b99d9ada70c0dad059.json')
print(video.json())
require 'json'

# Simple API
video = factory.videos.find("472cd69174c4d2b99d9ada70c0dad059")
puts(JSON.pretty_generate(video.attributes))

# REST API
video = tc.get("/videos/472cd69174c4d2b99d9ada70c0dad059.json")
puts(JSON.pretty_generate(video))
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  video, err := factory.Video("175afd050df3e6d5aac111f2c7b51d0c")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(video)
}

Returns a Video object.

Required Parameters

parameters attributes
id ID of the Video object.

Example request

require 'json'

# Simple API
encodings = factory.videos.find("472cd69174c4d2b99d9ada70c0dad059").encodings()
encodings.each { |enc|
    puts(JSON.pretty_generate(enc.attributes))
}

# REST API
encodings = TelestreamCloud.get("/videos/472cd69174c4d2b99d9ada70c0dad059/encodings.json")
puts(JSON.pretty_generate(encodings))
## Simple API
encodings = factory.videos.find("472cd69174c4d2b99d9ada70c0dad059").encodings()
for enc in encodings:
    print(enc.details)

## REST API
import json
encodings_response = tc.get('/videos/472cd69174c4d2b99d9ada70c0dad059/encodings.json')
for en in encodings_response.json():
    print(en.details)
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  encodings, err := factory.VideoEncodings("472cd69174c4d2b99d9ada70c0dad059",
    &flip.EncodingRequest{
      Page:    1,
      PerPage: 100,
    })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(encodings)
}

Example response

{
  "id": "cae49ee29684d8cc5c85baa6cf698fe8",
  "status": "success",
  "created_at": "2016/03/09 13:49:40 +0000",
  "updated_at": "2016/03/09 13:49:47 +0000",
  "started_encoding_at": "2016/03/09 13:49:42 +0000",
  "encoding_time": 4,
  "encoding_progress": 100,
  "video_id": "04b73c8cfc9da71f8f404a2cd5463402",
  "profile_id": "58a9667cd7e626c87d3a31cbbabd3a7a",
  "profile_name": "h264",
  "files": [
    "eefdf44c1cba7fe6251bcdb48f0ef7b3/cae49ee29684d8cc5c85baa6cf698fe8.mp4"
  ],
  "mime_type": "video/mp4",
  "duration": 14015,
  "height": 480,
  "width": 600,
  "extname": ".mp4",
  "file_size": 967151,
  "video_bitrate": 421,
  "audio_bitrate": 127,
  "audio_codec": "aac",
  "video_codec": "h264",
  "fps": 29.97,
  "audio_channels": 2,
  "audio_sample_rate": 44100,
  "path": "eefdf44c1cba7fe6251bcdb48f0ef7b3/cae49ee29684d8cc5c85baa6cf698fe8",
  "logfile_url": null
}

GET /videos/:id/encodings.json

Returns a collection of Encoding objects connected to specified Video object.

Required Parameters

parameters attributes
id ID of the Video object.

Optional Parameters

parameters attributes
status One of success, fail, processing. Filter by status.
profile_id Filter by profile_id.
profile_name Filter by profile_name.
screenshots If set adds extra field to Encoding objects with list of created screenshots. By default is not set.
page Default is 1.
per_page Default is 100.

Example request

require 'json'

# Simple API
metadata = factory.videos.find("472cd69174c4d2b99d9ada70c0dad059").metadata
puts(JSON.pretty_generate(metadata))

# REST API
metadata = TelestreamCloud.get("/videos/472cd69174c4d2b99d9ada70c0dad059/metadata.json")
puts(JSON.pretty_generate(metadata))
# Simple API
metadata = factory.videos.find("472cd69174c4d2b99d9ada70c0dad059").metadata()
print(metadata)

# REST API
import json
metadata_response = tc.get('/videos/472cd69174c4d2b99d9ada70c0dad059/metadata.json')
print(metadata_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  metadata, err := factory.VideoMetaData("472cd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(metadata)
}

Example response

{
  "file_name": "04b73c8cfc9da71f8f404a2cd5463402.mp4",
  "file_size": "786 kB",
  "file_type": "MP4",
  "mime_type": "video/mp4",
  "major_brand": "MP4  Base Media v1 [IS0 14496-12:2003]",
  "minor_version": "0.0.1",
  "compatible_brands": "isom",
  "movie_data_size": 799477,
  "movie_data_offset": 28,
  "movie_header_version": 0,
  "create_date": "2007/01/10 05:52:05 +0000",
  "modify_date": "2007/01/10 05:52:05 +0000",
  "time_scale": 600,
  "duration": "14.01 s",
  "preferred_rate": 1,
  "preferred_volume": "100.00%",
  "preview_time": "0 s",
  "preview_duration": "0 s",
  "poster_time": "0 s",
  "selection_time": "0 s",
  "selection_duration": "0 s",
  "current_time": "0 s",
  "next_track_id": 3,
  "track_header_version": 0,
  "track_create_date": "2007/01/10 05:52:05 +0000",
  "track_modify_date": "2007/01/10 05:52:05 +0000",
  "track_id": 1,
  "track_duration": "14.01 s",
  "track_layer": 0,
  "track_volume": "0.00%",
  "image_width": 300,
  "image_height": 240,
  "graphics_mode": "srcCopy",
  "op_color": "0 0 0",
  "compressor_id": "avc1",
  "source_image_width": 300,
  "source_image_height": 240,
  "x_resolution": 72,
  "y_resolution": 72,
  "bit_depth": 24,
  "buffer_size": 18365,
  "max_bitrate": 497320,
  "average_bitrate": 344632,
  "video_frame_rate": 29.969,
  "matrix_structure": "1 0 0 0 1 0 0 0 1",
  "media_header_version": 0,
  "media_create_date": "2007/01/10 05:52:05 +0000",
  "media_modify_date": "2007/01/10 05:52:05 +0000",
  "media_time_scale": 44100,
  "media_duration": "13.86 s",
  "media_language_code": "und",
  "handler_description": "GPAC ISO Audio Handler",
  "balance": 0,
  "audio_format": "mp4a",
  "audio_channels": 2,
  "audio_bits_per_sample": 16,
  "audio_sample_rate": 44100,
  "handler_type": "Metadata",
  "handler_vendor_id": "Apple",
  "title": "Panda Sneezes",
  "avg_bitrate": "456 kbps",
  "image_size": "300x240",
  "rotation": 0
}

GET /videos/:id/metadata.json

Just after the media is uploaded, we analyze and store the metadata that we can extract from it.

Required Parameters

parameters attributes
id ID of the Video object.

Example request

require 'json'

# Simple API
video = factory.videos.create(
    :source_url => "http://example.com/file.mp4",
    :path_format => "examples/:id",
    :profiles => "h264")
puts(JSON.pretty_generate(video.attributes))

# REST API
video = TelestreamCloud.post("/videos.json",
    :source_url => "http://example.com/file.mp4",
    :path_format => "examples/:id",
    :profiles => "h264")
puts(JSON.pretty_generate(video))
# Simple API
video = factory.videos.create(
    source_url="http://example.com/file.mp4",
    path_format="examples/:id",
    profiles="h264")
print(video.details)

# REST API
import json
video_response = tc.post('/videos.json', {
    "source_url": "http://example.com/file.mp4",
    "path_format": "examples/:id",
    "profiles": "h264" })
print(video_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  video, err := factory.NewVideoURL("http://example.com/file.mp4",
    &flip.NewVideoRequest{
      Profiles:   []string{"h264", "h265"},
      PathFormat: "examples/:id",
    })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(video)
}

Example response

{
  "status": "processing",
  "audio_channels": null,
  "original_filename": "t.mp4",
  "updated_at": "2015/05/04 12:12:38 +0000",
  "source_url": "http://example.com/file.mp4",
  "audio_bitrate": null,
  "audio_codec": null,
  "file_size": null,
  "duration": null,
  "path": "examples/ba9f256cf7bceaeab113e6480b4cfdfe",
  "height": null,
  "audio_sample_rate": null,
  "created_at": "2015/05/04 12:12:38 +0000",
  "extname": ".mp4",
  "width": null,
  "id": "ba9f256cf7bceaeab113e6480b4cfdfe",
  "fps": null,
  "video_codec": null,
  "video_bitrate": null,
  "mime_type": null
}

POST /videos.json

If you use Telestream Cloud in your web application, you’ll probably want to use our Telestream Cloud uploader to upload video files from a web page. Otherwise, you can use this API to upload videos. It allows to send multimedia files easily using a single POST request. The main disadvantage of this approach is that in case of connection failure it doesn’t allow to resume the process, which makes it inapplicable for larger files. For these it’s better to create an upload session through the /videos/upload.json endpoint

Required Parameters

parameters attributes
file The file that is being uploaded.
source_url Url of a remote video file.

If you use the file parameter, make sure that your HTTP request uses an appropriate Content-Type, such as multipart/form-data.

Also, it’s possible to create video with source URL which is FASP (Aspera Enterprise Server) URL. In order to do that, URL should follow FASP spec:

<scheme>://<user>:<password>@<host>:<port>/<path>?<parameters>

The following are examples of FASP URLs:

Optional Parameters

parameters attributes
profiles Comma-separated list of profile names or IDs to be used during encoding. Alternatively, specify none so no encodings are created yet.
path_format Represents the complete video path without the extension name. It can be constructed using some provided keywords.
payload Arbitrary string stored along the Video object.
pipeline JSON describing profiles pipeline.
subtitle_files Comma-seperated list of urls of a remote subtitle files.

Example path format

"my-path/:video_id/:profile/:id"

Path Format

The following keywords can be combined to create a path format.

parameters attributes
id ID of the encoding. Required.
video_id ID of the video.
original Original filename of the uploaded video
date Date the video was uploaded (2009-10-09).
profile Profile name used by the encoding (original is used when the file is the original video).
type Video type, original or encodings.
resolution Resolution of the video or the encoding (480x340).

By default path_format is set to :id.

Payload

The payload is an arbitrary text of length 256 or shorter that you can store along the Video. It is typically used to retain an association with one of your own DB record ID.

Example request

# Simple API
us = TelestreamCloud::UploadSession.new("panda.mp4", profiles: "webm")
puts us.location

# REST API
require 'json'
data = TelstreamCloud.post("/videos/upload.json",
    :file_size => 21264,
    :file_name => "panda.mp4"
)
puts(JSON.pretty_generate(data))
# Simple API
us = factory.upload_session("file.mp4")
print(us.location)

# REST API
import json
data = tc.post('/videos/upload.json',
               {"file_size": 21264,
                "file_name": "panda.mp4"})
print(data.json())

Example response

{
  "id": "3a8795b8d2755a554ea28279c769bba9",
  "location": "https://vm-u5a6i9.upload.pandastream.com/upload/session?id=3a8795b8d2755a554ea28279c769bba9"
}

POST /videos/upload.json

Creates an upload session and returns its unique endpoint location, which can be used to upload multimedia file in chunks using upload API .

Required parameters

parameters attributes
file_size Size in bytes of the video.
file_name File name of the video.

Optional parameters

parameters attributes
use_all_profiles Default is false.
profiles Comma-separated list of profile names or IDs to be used during encoding. Alternatively, specify none so no encodings are created yet.
path_format Represents the complete video path without the extension name. It can be constructed using some provided keywords.
payload Arbitrary string stored along the Video object.
pipeline JSON describing profiles pipeline.

Example request

# Simple API
video = TelestreamCloud::Video.find("94b73d8171e1a4662dc9109b32e528c6")
video.resubmit
puts(JSON.pretty_generate(video))

# REST API
require 'json'
video = TelestreamCloud.post("/videos/resubmit.json",
    :video_id => '94b73d8171e1a4662dc9109b32e528c6'
)
puts(JSON.pretty_generate(video))

Example response

{
  "id": "7a7217748c9b158c11d752cc7300f632",
  "status": "processing",
  "created_at": "2016/04/11 17:12:56 +0200",
  "updated_at": "2016/04/11 17:12:56 +0200",
  "mime_type": "video/mp4",
  "original_filename": "panda.mp4",
  "source_url": "https://storage.googleapis.com/marcinp-test/94b73d8171e1a4662dc9109b32e528c6.mp4",
  "duration": 14014,
  "height": 240,
  "width": 300,
  "extname": ".mp4",
  "file_size": 805301,
  "video_bitrate": 344,
  "audio_bitrate": 112,
  "audio_codec": "aac",
  "video_codec": "h264",
  "fps": 29.97,
  "audio_channels": 2,
  "audio_sample_rate": 44100,
  "path": "7a7217748c9b158c11d752cc7300f632",
  "encodings_count": 1
}

POST /videos/resubmit.json

Resubmits the video to encode. Please note that this option will work only for videos in success status.

Required parameters

parameters attributes
video_id Id of the video.

Example request

require 'json'

## Simple API
video = factory.videos.find("a6daf6589b9c714fb8c2928d916a87ca")
video.delete

# REST API
ret = TelestreamCloud.delete("/videos/cce990c5658e45fafb5329aa779c9018.json")
puts(JSON.pretty_generate(ret))
# Simple API
video = factory.videos.find("730d5677101fa5610b5db46cddbe72a8")
video.delete()

# REST API
import json
video_delete_response = tc.delete('/videos/2474768f8cb58ffd0192696701c0e4ad.json')
print(video_delete_response.json())
package main

import (
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  video, err := factory.Video("2474768f8cb58ffd0192696701c0e4ad")
  if err != nil {
    log.Fatal(err)
  }
  if err := factory.Delete(video); err != nil {
    log.Fatal(err)
  }
}

Example response

{
  "deleted": true
}

DELETE /videos/:id.json

Deletes requested video from Telestream Cloud and your storage. Returns an information whether the operation was successful.

Required Parameters

parameters attributes
id ID of the Video object.

Example request

require 'json'

# REST API
ret = TelestreamCloud.delete("/videos/f7849488f82dd0c75fce910a88a1af74/source.json")
puts(JSON.pretty_generate(ret))
# REST API
import json
ret = tc.delete("/videos/c8a995f749eca5ce2daab627ffb66ed8/source.json")
print(ret.json())
package main

import (
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  if err := factory.
    VideoDeleteSource("2474768f8cb58ffd0192696701c0e4ad"); err != nil {
    log.Fatal(err)
  }
}

Example response

{
  "deleted": true
}

DELETE /videos/:id/source.json

Deletes only source file from storage.

Required Parameters

parameters attributes
id ID of the Video object.

Encodings

Each encoding represents a version of a video encoded with the settings defined in the profile used. When an encoding is created (either automatically when a video is uploaded, or using the POST method below) it is immediately placed on your encoding queue.

If the original video has been successfully downloaded, the video status will be set to success. If the video has failed, the encoding will fail as well.

If the encoding was successful, you can download it or play it using the following convention $path$$extname$. Both values can be retrieved using the API.

If the encoding fails, this is usually because there was either an invalid profile being used, or the origin video is corrupted or not recognised. In this case, a logfile will be uploaded to your storage (with the filename $path$.log) containing some debug information which can help in correcting issues caused by an invalid profile.

Example request

require 'json'

# Simple API
encodings = factory.encodings.all
encodings.each { |enc|
    puts(JSON.pretty_generate(enc.attributes))
}

# REST API
encodings = TelestreamCloud.get("/encodings.json")
puts(JSON.pretty_generate(encodings))
# Simple API
encodings = factory.encodings.all()
for enc in encodings:
    print(enc.details)

# REST API
import json
encodings_response = tc.get('/encodings.json')
print(encodings_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  encodings, err := factory.Encodings(&flip.EncodingRequest{
    Page:    1,
    PerPage: 100,
  })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(encodings)
}

Example response

{
  "id": "de9ebb55479e3b682eb4e5615df14392",
  "status": "success",
  "created_at": "2015/05/04 14:52:52 +0000",
  "updated_at": "2015/05/04 14:54:02 +0000",
  "started_encoding_at": "2015/05/04 14:53:01 +0000",
  "encoding_time": 35,
  "encoding_progress": 100,
  "video_id": "e427da58f8042bc20b150ef2da7bf6f1",
  "profile_id": "9097cfc74bc176b51fa9db707457b29c",
  "profile_name": "h264",
  "files": [
    "de9ebb55479e3b682eb4e5615df14392.mp4"
  ],
  "mime_type": "video/mp4",
  "duration": 14015,
  "height": 480,
  "width": 600,
  "extname": ".mp4",
  "file_size": 966710,
  "video_bitrate": 421,
  "audio_bitrate": 127,
  "audio_codec": "aac",
  "video_codec": "h264",
  "fps": 29.97,
  "audio_channels": 2,
  "audio_sample_rate": 44100,
  "path": "de9ebb55479e3b682eb4e5615df14392",
  "factory_id": "1297c22da25dd3ce3ea64513eda642be"
}

GET /encodings.json

Returns a collection of Encoding objects.

Optional parameters

parameters attributes
status One of success, fail, processing. Filter by status.
profile_id Filter by profile_id.
profile_name Filter by profile_name.
video_id Filter by video_id.
screenshots If set adds extra field to Encoding objects with list of created screenshots. By default is not set.
page Default is 1.
per_page Default is 100.

Example request

# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
print(enc.details)

# REST API
encoding_response = tc.get("/encodings/de9ebb55479e3b682eb4e5615df14392.json")
print(encoding_response.json())
require 'json'

# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
puts(JSON.pretty_generate(enc.attributes))

# REST API
enc = TelestreamCloud.get("/encodings/de9ebb55479e3b682eb4e5615df14392.json")
puts(JSON.pretty_generate(enc))
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  encoding, err := factory.Encoding("de9ebb55479e3b682eb4e5615df14392")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(encoding)
}

GET /encodings/:id.json

Returns a Encoding object.

Required Parameters

parameters attributes
id ID of the Encoding object.
screenshots If set adds extra field to Encoding objects with list of created screenshots. By default is not set.

Example request

require 'json'

# Simple API
enc = factory.encodings.create(
    :video_id => "788dfd45b9bef06d9c93c426e936fa9a",
    :profile_name => "h264")
puts(JSON.pretty_generate(enc.attributes))

# REST API
video = TelestreamCloud.post("/encodings.json",
    :video_id => "a321dcc4418dd5ea2d30c11f655c3646",
    :profile_name => "h264")
puts(JSON.pretty_generate(video))
imple API
enc = factory.encodings.create(
               video_id = "9c6b1114d01011fa50b4e7eddd642009",
               profile_name = "h264")
print(enc.details)

# REST API
import json
encoding_response = tc.post('/encodings.json', {
                 "video_id": "95bdade61f551b49aa969586f914eca1",
                 "profile_name": "h264"})
print(encoding_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  encoding, err := factory.NewEncoding(&flip.NewEncodingRequest{
    VideoID:     "a321dcc4418dd5ea2d30c11f655c3646",
    ProfileName: "h264",
  })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(encoding)
}

Example response

{
  "id": "26121714b09447843e821d0528fbe106",
  "status": "processing",
  "created_at": "2015/05/04 15:20:42 +0000",
  "updated_at": "2015/05/04 15:20:42 +0000",
  "started_encoding_at": null,
  "encoding_time": null,
  "encoding_progress": null,
  "video_id": "a321dcc4418dd5ea2d30c11f655c3646",
  "profile_id": "9097cfc74bc176b51fa9db707457b29c",
  "profile_name": "h264",
  "files": [

  ],
  "mime_type": null,
  "duration": null,
  "height": null,
  "width": null,
  "extname": ".mp4",
  "file_size": null,
  "video_bitrate": null,
  "audio_bitrate": null,
  "audio_codec": null,
  "video_codec": null,
  "fps": null,
  "audio_channels": null,
  "audio_sample_rate": null,
  "path": "26121714b09447843e821d0528fbe106"
}

POST /encodings.json

Create a new encoding for a video that already exists.

Required parameters

One of the profile_id or profile_name parameter is required:

parameters attributes
video_id ID of existing video.
profile_id ID of existing profile.
profile_name Name of existing profile.
screenshots If set adds extra field to Encoding objects with list of created screenshots. By default is not set.

Example request

# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
enc.cancel()

# REST API
TelestreamCloud.post("/encodings/de9ebb55479e3b682eb4e5615df14392/cancel.json")
# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
enc.cancel()

# REST API
cancel_response = tc.post('/encodings/de9ebb55479e3b682eb4e5615df14392/cancel.json')
package main

import (
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  if err := factory.CancelEncoding("de9ebb55479e3b682eb4e5615df14392"); err != nil {
    log.Fatal(err)
  }
}

POST /encodings/:id/cancel.json

Cancel an encoding. Returns nothing.

Required Parameters

parameters attributes
id ID of the Encoding object.

Example request

# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
enc.retry()

# REST API
TelestreamCloud.post("/encodings/de9ebb55479e3b682eb4e5615df14392/retry.json")
# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
enc.retry()

# REST API
retry_response = tc.post('/encodings/de9ebb55479e3b682eb4e5615df14392/retry.json')
package main

import (
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  if err := factory.RetryEncoding("a321dcc4418dd5ea2d30c11f655c3646"); err != nil {
    log.Fatal(err)
  }
}

POST /encodings/:id/retry.json

Retry a failed encoding. Returns nothing.

Required Parameters

parameters attributes
id ID of the Encoding object.

Example request

# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
enc.delete()

# REST API
video = TelestreamCloud.delete("/encodings/de9ebb55479e3b682eb4e5615df14392.json")
# Simple API
enc = factory.encodings.find("de9ebb55479e3b682eb4e5615df14392")
enc.delete()

# REST API
delete_response = tc.delete('/encodings/de9ebb55479e3b682eb4e5615df14392.json')
package main

import (
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  encoding, err := factory.Encoding("de9ebb55479e3b682eb4e5615df14392")
  if err != nil {
    log.Fatal(err)
  }
  if err := factory.Delete(&encoding); err != nil {
    log.Fatal(err)
  }
}

Example response

{
  "deleted": true
}

DELETE /encodings/:id.json

Deletes requested encoding from Telestream Cloud and your storage. Returns an information whether the operation was successful

Required Parameters

parameters attributes
id ID of the Encoding object.

Profiles

Example request

require 'json'

# Simple API
profiles = factory.profiles.all
profiles.each { |prof|
    puts(JSON.pretty_generate(prof.attributes))
}

# REST API
profiles = TelestreamCloud.get("/profiles.json")
puts(JSON.pretty_generate(profiles))
# Simple API
profiles = factory.profiles.all()
for profile in profiles:
    print(profile.details)

# REST API
import json
profiles_response = tc.get('/profiles.json')
print(profiles_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  profiles, err := factory.Profiles(&flip.ProfileRequest{
    Page:    1,
    PerPage: 100,
  })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(profiles)
}

Example response

{
  "keyframe_interval": 250,
  "preset_name": "h264",
  "updated_at": "2015/05/04 10:03:50 +0000",
  "height": 480,
  "width": 640,
  "upscale": true,
  "audio_bitrate": 128,
  "id": "9097cfc74bc176b51fa9db707457b29c",
  "audio_sample_rate": 44100,
  "name": "h264",
  "title": "MP4 (H.264)",
  "video_bitrate": null,
  "extname": ".mp4",
  "priority": null,
  "add_timestamp": null,
  "aspect_mode": "letterbox",
  "created_at": "2015/05/04 10:03:50 +0000"
}

GET /profiles.json

Returns a collection of Profile objects.

Optional parameters

parameters attributes
expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default is not set.
page Default is 1.
per_page Default is 100.

Example request

require 'json'

# Simple API
prof = factory.profiles.find("9097cfc74bc176b51fa9db707457b29c")
puts(JSON.pretty_generate(prof.attributes))

# REST API
prof = TelestreamCloud.get("/profiles/9097cfc74bc176b51fa9db707457b29c.json")
puts(JSON.pretty_generate(prof))
# Simple API
profile = factory.profiles.find("9097cfc74bc176b51fa9db707457b29c")
print(profile.details)

# REST API
import json
profile_response = tc.get('/profiles/9097cfc74bc176b51fa9db707457b29c.json')
print(profile_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  profile, err := factory.Profile("9097cfc74bc176b51fa9db707457b29c")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(profile)
}

Example response

{
  "keyframe_interval": 250,
  "preset_name": "h264",
  "updated_at": "2015/05/04 10:03:50 +0000",
  "height": 480,
  "width": 640,
  "upscale": true,
  "audio_bitrate": 128,
  "id": "9097cfc74bc176b51fa9db707457b29c",
  "audio_sample_rate": 44100,
  "name": "h264",
  "title": "MP4 (H.264)",
  "video_bitrate": null,
  "extname": ".mp4",
  "priority": null,
  "add_timestamp": null,
  "aspect_mode": "letterbox",
  "created_at": "2015/05/04 10:03:50 +0000"
}

GET /profiles/:id_or_name.json

Returns a Profile object.

Required Parameters

parameters attributes
id_or_name ID or name of the Profile object.
expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default is not set.

POST /profiles.json

Adds new profile to Factory. It can be used later to encode videos.

Using presets

Example request

require 'json'

# Simple API
prof = factory.profiles.create(
    :preset_name => "h264",
    :name => "h264_1",
    :fps => 45
)
puts(JSON.pretty_generate(prof.attributes))

# REST API
prof = TelestreamCloud.post("/profiles.json",
        :preset_name => "h264",
        :name => "h264_2",
        :fps => 45
)
puts(JSON.pretty_generate(prof))
# Simple API
prof = factory.profiles.create(
    preset_name = "h264",
    name = "h264_1",
    fps = 45
)
print(prof.details)

# REST API
import json
profile_response = tc.post('/profiles.json', {
    "preset_name": "h264",
    "name": "h264_2",
    "fps": 45
})
print(profile_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  profile, err := factory.NewProfile(&flip.NewProfileRequest{
    PresetName:   "h264",
    AspectMode:   flip.ModeLetterBox,
    Fps:          45.0,
    Name:         "h264_1",
    Width:        640,
    Height:       480,
  })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(profile)
}

Example response

{
  "id": "51622c67ea55bcfb698e34398b8e06ba",
  "name": "h264_1",
  "priority": 0,
  "created_at": "2015/05/18 13:21:21 +0000",
  "updated_at": "2015/05/18 13:21:21 +0000",
  "extname": ".mp4",
  "audio_sample_rate": 44100,
  "keyframe_interval": 250,
  "fps": 45.0,
  "aspect_mode": "letterbox",
  "add_timestamp": false,
  "title": "MP4 (H.264)",
  "preset_name": "h264",
  "upscale": true,
  "width": 640,
  "height": 480,
  "video_bitrate": null,
  "audio_bitrate": 128,
  "factory_id": "1297c22da25dd3ce3ea64513eda642be"
}

Required parameters

parameters attributes
preset_name Name of preset to use.

Optional parameters

parameters attributes
name Unique machine-readable name that will identify the profile. Helpful later on for filtering encodings by profile.
title Human-readable name.
extname File extension. Example: ".mp4".
width Width in pixels. Example: 1080.
height Height in pixels. Example: 720.
upscale Upscale the video resolution to match your profile. Default is true.
aspect_mode Default is "letterbox".
aspect_ratio Sets the desired display aspect ratio. By default it is not set.
two_pass Default is false.
video_bitrate Example: 3000.
fps Null value copy the original fps. By default it is not set. Example: 29.97.
keyframe_interval Adds a key frame every 250 frames. Default is 250, adds a key frame every 250 frames.
keyframe_rate Example: 0.5, adds a key frame every 2 seconds.
audio_bitrate Example: 128.
audio_sample_rate Default is 44100.
audio_channels By default it is not set.
clip_length Sets the clip’s duration. Example: "00:20:00".
clip_offset Clip starts at a specific offset. Example: "00:00:10".
watermark_url Url of the watermark image.
watermark_top Distance from the top of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_bottom Distance from the bottom of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_left Distance from the left of the video frame in pixels or percentage of video frame width. Works like CSS. Default is 0.
watermark_right Distance from the right of the video frame in pixels or percentage of video frame width. Works like CSS. Default is 0.
watermark_width Width of the watermark image in pixels or percentage of video frame width. Default is no resizing.
watermark_height Height of the watermark image in pixels or percentage of video frame height. Default is no resizing.
expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default is not set.
time_code Adds timestamp to your video. By default is not set.
add_timestamp Deprecated. Please use time_code instead. Adds timestamp to your video. By default is not set.
max_rate By default is not set.
buffer_size By default is not set.
deinterlace One of keep_fps or double_fps. By default is not set.
frame_count Evenly spaced number of generated screenshots. By default is not set.
frame_offsets Array of offset (Frames or seconds). Example: "2s, 10s, 250f, 400f"
frame_interval Thumbnail interval (Frames or seconds). Example: "1000f".

Aspect Modes

parameters attributes
preserve Original size and ratio is preserved.
constrain Aspect ratio is maintained.
No black bars is added to your output.
letterbox Aspect ratio is maintained.
Adds black bars to your output to match your profile frame height (above and below only).
pad Aspect ratio is maintained.
Adds black bars to your output to match your profile frame size.
fill (crop) Aspect ratio is maintained.
fills your profile frame size and crops the rest.
stretch Aspect is not maintained. Image is stretched so that both dimensions are equal to the target image dimensions.
center The source image is centered in the target image without scaling. A lesser dimension is filled, a greater dimension is cropped.

H264 preset

parameters attributes
h264_crf Example: 23.
h264_profile Example: "baseline".
h264_level Example: "3.1".
closed_captions One of add (adds captions as seperate streams) or burn (burns captions on video stream using first subtitle file). By default is not set.

JPEG preset

parameters attributes
frame_count Evenly spaced number of thumbnails. Example: 7.
frame_offsets Array of offset (Frames or seconds). Example: "2s, 10s, 250f, 400f"
frame_interval Thumbnail interval (Frames or seconds). Example: "1000f".

HLS.Variant.Playlist presets

parameters attributes
variants Pattern to match HLS.Variant presets by name. Default is hls.*.

Using custom settings

Example request

# Simple API
prof = factory.profiles.create(
    :title => "H264 normal quality",
    :name => "h264_1",
    :extname => ".mp4",
    :width => 320,
    :height => 240,
    :audio_bitrate => 128,
    :video_bitrate => 500,
    :aspect_mode => "pad",
    :command => "ffmpeg -i $input_file$ -c:a libfaac $audio_bitrate$ -c:v libx264 $video_bitrate$ -preset medium $filters$ -y $output_file$")
puts(JSON.pretty_generate(prof.attributes))

# REST API
prof = TelestreamCloud.post("/profiles.json",
    :title => "H264 normal quality",
    :name => "h264_2",
    :extname => ".mp4",
    :width => 320,
    :height => 240,
    :audio_bitrate => 128,
    :video_bitrate => 500,
    :aspect_mode => "pad",
    :command => "ffmpeg -i $input_file$ -c:a libfaac $audio_bitrate$ -c:v libx264 $video_bitrate$ -preset medium $filters$ -y $output_file$")
puts(JSON.pretty_generate(prof))
# Simple API
prof = factory.profiles.create(
    title = "H264 normal quality",
    name = "h264_1",
    extname = ".mp4",
    width = 320,
    height = 240,
    audio_bitrate = 128,
    video_bitrate = 500,
    aspect_mode = "pad",
    command = "ffmpeg -i $input_file$ -c:a libfaac $audio_bitrate$ -c:v libx264 $video_bitrate$ -preset medium $filters$ -y $output_file$")
print(prof.details)

# REST API
import json
profile_response = tc.post('/profiles.json', {
    "title": "H264 normal quality",
    "name": "h264_2",
    "extname": ".mp4",
    "width": 320,
    "height": 240,
    "audio_bitrate": 128,
    "video_bitrate": 500,
    "aspect_mode": "pad",
    "command": "ffmpeg -i $input_file$ -c:a libfaac $audio_bitrate$ -c:v libx264 $video_bitrate$ -preset medium $filters$ -y $output_file$" })
print(profile_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  profile, err := factory.NewProfile(&flip.NewProfileRequest{
    Command:      "ffmpeg -i $input_file$ -c:a libfaac $audio_bitrate$ -c:v libx264 $video_bitrate$ -preset medium $filters$ -y $output_file$",
    Extname:      ".mp4",
    AspectMode:   flip.ModePad,
    Name:         "h264_2",
    Width:        320,
    Height:       240,
    AudioBitrate: 128,
    VideoBitrate: 500,
  })
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(profile)
}

Example response

{
  "updated_at": "2015/05/18 13:34:41 +0000",
  "height": 240,
  "width": 320,
  "upscale": true,
  "audio_bitrate": 128,
  "id": "dcdeb1f15f9a344bb67f0623fa55c1a3",
  "stack": "corepack-1",
  "name": "h264_1",
  "title": "H264 normal quality",
  "video_bitrate": 500,
  "extname": ".mp4",
  "priority": 0,
  "add_timestamp": false,
  "command": "ffmpeg -i $input_file$ -c:a libfaac $audio_bitrate$ -c:v libx264 $video_bitrate$ -preset medium $filters$ -y $output_file$",
  "aspect_mode": "pad",
  "full_command": "The recipe tried to use ffmpeg which does not exist",
  "created_at": "2015/05/18 13:34:41 +0000"
}

Required parameters

parameters attributes
command Line break separated list of encoding commands to run.
extname File extension. Example: ".mp4".

Optional parameters

parameters attributes
name Unique machine-readable name that will identify the profile. Helpful later on for filtering encodings by profile.
title Human-readable name.
stack The name of the stack to use. One of corepack-2, corepack-3, corepack-4. By default is not set.
width Width in pixels. Example: 1080.
height Height in pixels. Example: 720.
upscale Upscale the video resolution to match your profile. Default is true.
aspect_mode Default is "letterbox".
aspect_ratio Sets the desired display aspect ratio. By default it is not set.
two_pass Default is false.
video_bitrate Example: 3000.
fps Null value copy the original fps. By default it is not set. Example: 29.97.
keyframe_interval Adds a key frame every 250 frames. Default is 250, adds a key frame every 250 frames.
keyframe_rate Example: 0.5, adds a key frame every 2 seconds.
audio_bitrate Example: 128.
audio_sample_rate Default is 44100.
audio_channels By default it is not set.
clip_length Sets the clip’s duration. Example: "00:20:00".
clip_offset Clip starts at a specific offset. Example: "00:00:10".
watermark_url Url of the watermark image.
watermark_top Distance from the top of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_bottom Distance from the bottom of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_left Distance from the left of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_right Distance from the right of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_width Width of the watermark image. Default is no resizing.
watermark_height Height of the watermark image. Default is no resizing.
frame_count Evenly spaced number of generated screenshots. By default is not set.
expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default is not set.
add_timestamp Adds timestamp to your video. By default is not set.
max_rate By default is not set.
buffer_size By default is not set.
deinterlace One of keep_fps or double_fps. By default is not set.

Example request

require 'json'

# Simple API
prof = factory.profiles.find("9097cfc74bc176b51fa9db707457b29c")
prof.video_bitrate = 1200
prof.fps = 40
prof.save()
puts(JSON.pretty_generate(prof.attributes))

# REST API
prof = TelestreamCloud.put("/profiles/9097cfc74bc176b51fa9db707457b29c.json", {
    :video_bitrate => 1200,
    :fps => 40
})
puts(JSON.pretty_generate(prof))
# Simple API
prof = factory.profiles.find("9097cfc74bc176b51fa9db707457b29c")
prof.update(
    video_bitrate = 1200,
    fps = 40
)
prof = prof.save()
print(prof.details)

# REST API
import json
profile_response = tc.put('/profiles/9097cfc74bc176b51fa9db707457b29c.json', {
    "video_bitrate": 1200,
    "fps": 40
})
print(profile_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  profile, err := factory.Profile("9097cfc74bc176b51fa9db707457b29c")
  if err != nil {
    log.Fatal(err)
  }
  profile.Fps = 40
  profile.VideoBitrate = 1200
  if err := factory.Update(profile); err != nil {
    log.Fatal(err)
  }
  fmt.Println(profile)
}

Example response

{
  "preset_name": "h264",
  "name": "h264",
  "video_bitrate": 1250,
  "fps": 40.0,
  "created_at": "2015/05/04 10:03:50 +0000",
  "title": "MP4 (H.264)",
  "updated_at": "2015/05/19 08:07:24 +0000",
  "extname": ".mp4",
  "priority": 0,
  "add_timestamp": false,
  "width": 640,
  "upscale": false,
  "aspect_mode": "letterbox",
  "audio_sample_rate": 44100,
  "audio_bitrate": 128,
  "height": 480,
  "id": "9097cfc74bc176b51fa9db707457b29c",
  "keyframe_interval": 250
}

PUT /profiles/:id.json

Edit existing profile settings.

Required parameters

parameters attributes
id ID of the Profile object.

Optional parameters

parameters attributes
name Unique machine-readable name that will identify the profile. Helpful later on for filtering encodings by profile.
title Human-readable name.
stack The name of the stack to use. One of corepack-2, corepack-3, corepack-4. By default is not set.
extname File extension. Example: ".mp4".
width Width in pixels. Example: 1080.
height Height in pixels. Example: 720.
upscale Upscale the video resolution to match your profile. Default is true.
aspect_mode Default is "letterbox".
aspect_ratio Sets the desired display aspect ratio. By default it is not set.
two_pass Default is false.
video_bitrate Example: 3000.
fps Null value copy the original fps. By default it is not set. Example: 29.97.
keyframe_interval Adds a key frame every 250 frames. Default is 250, adds a key frame every 250 frames.
keyframe_rate Example: 0.5, adds a key frame every 2 seconds.
audio_bitrate Example: 128.
audio_sample_rate Default is 44100.
audio_channels By default it is not set.
clip_length Sets the clip’s duration. Example: "00:20:00".
clip_offset Clip starts at a specific offset. Example: "00:00:10".
watermark_url Url of the watermark image.
watermark_top Distance from the top of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_bottom Distance from the bottom of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_left Distance from the left of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_right Distance from the right of the video frame in pixels or percentage of video frame height. Works like CSS. Default is 0.
watermark_width Width of the watermark image. Default is no resizing.
watermark_height Height of the watermark image. Default is no resizing.
frame_count Evenly spaced number of generated screenshots. By default is not set.
expand If expand option is set Profile objects will contain all command parameters, even if their value is default. By default is not set.
add_timestamp Deprecated. Please use time_code instead. Adds timestamp to your video. By default is not set.
max_rate By default is not set.
buffer_size By default is not set.
deinterlace One of keep_fps or double_fps. By default is not set.

Aspect Modes

parameters attributes
preserve Original size and ratio is preserved.
constrain Aspect ratio is maintained.
No black bars is added to your output.
letterbox Aspect ratio is maintained.
Adds black bars to your output to match your profile frame height (above and below only).
pad Aspect ratio is maintained.
Adds black bars to your output to match your profile frame size.
crop Aspect ratio is maintained.
fills your profile frame size and crops the rest.

H264 preset

parameters attributes
h264_crf Example: 23.
h264_profile Example: "baseline".
h264_level Example: "3.1".
closed_captions One of add (adds captions as seperate streams) or burn (burns captions on video stream using first subtitle file). By default is not set.

JPEG preset

parameters attributes
frame_count Evenly spaced number of thumbnails. Example: 7.
frame_offsets Array of offset (Frames or seconds). Example: "2s, 10s, 250f, 400f"
frame_interval Thumbnail interval (Frames or seconds). Example: "1000f".

HLS.Variant.Playlist presets

parameters attributes
variants Pattern to match HLS.Variant presets by name. Default is hls.*.

Example request

# Simple API
prof = factory.profiles.find("a6daf6589b9c714fb8c2928d916a87ca")
prof.delete

# REST API
TelestreamCloud.delete("/profiles/cce990c5658e45fafb5329aa779c9018.json")
# Simple API
prof = factory.profiles.find("9097cfc74bc176b51fa9db707457b29c")
prof.delete()

# REST API
tc.delete('/profiles/de9ebb55479e3b682eb4e5615df14392.json')
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  profile, err := factory.Profile("9097cfc74bc176b51fa9db707457b29c")
  if err != nil {
    log.Fatal(err)
  }
  if err := factory.Delete(profile); err != nil {
    log.Fatal(err)
  }
  fmt.Println(profile)
}

Example response

{
  "deleted": true
}

DELETE /profiles/:id.json

Deletes requested profile from your Factory. Returns an information whether the operation was successful.

Required Parameters

parameters attributes
id ID of the Profile object.

Notifications

Example request

notif = TelestreamCloud.get("/notifications.json")
puts(JSON.pretty_generate(notif))
# Simple API
notifications = factory.get_notifications()
print(notifications)

# REST API
notif_response = tc.get("/notifications.json")
print(notif_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("477bd69174c4d2b99d9ada70c0dad059")
  if err != nil {
    log.Fatal(err)
  }
  notification, err := factory.Notifications()
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(notification)
}

Example response

{
  "url": "null",
  "events": {
    "video_created": false,
    "video_encoded": false,
    "encoding_progress": false,
    "encoding_completed": false
  },
  "delay": 10,
  "send_video_payload": false
}

GET /notifications.json

Returns a Notifiactions object.

Example request

require 'json'

# REST API
notif = TelestreamCloud.put("/notifications.json", {
  :delay => 15,
  :send_video_payload => true,
  :events => {
    :video_created => "true",
    :video_encoded => "true",
    :encoding_progress => "true",
    :encoding_completed => "true"
  }
})
puts(JSON.pretty_generate(notif))
# Simple API
factory.update_notifications({
    'delay': 13,
    'send_video_payload': True,
    'events': {
        'video_created': False,
        'video_encoded': True,
        'encoding_progress': False,
        'encoding_completed': False}
  })

# REST API
notif_response = tc.put("/notifications.json", {
    "send_video_payload": "true",
    "events": {
        "video_created": "true",
        "video_encoded": "false",
        "encoding_progress": "true",
        "encoding_completed": "true",
    }
})
print(notif_response.json())
package main

import (
  "fmt"
  "log"
  "os"

  "github.com/Telestream/telestream-cloud-go-sdk/flip"
)

func main() {
  factory, err := flip.NewFlip(os.Getenv("ACCESS_KEY"), os.Getenv("SECRET_KEY"),
    nil).Factory("dd1835cdef05510a979f1407c67a8b39")
  if err != nil {
    log.Fatal(err)
  }
  notification, err := factory.Notifications()
  if err != nil {
    log.Fatal(err)
  }
  notification.URL = "www.example.com"
  notification.Events.VideoEncoded = true
  if err := factory.Update(notification); err != nil {
    log.Fatal(err)
  }
  fmt.Println(notification)
}

Example response

{
  "url": "http://example.com/panda_notification",
  "events": {
    "video_created": false,
    "video_encoded": true,
    "encoding_progress": false,
    "encoding_completed": false
  },
  "delay": 10,
  "send_video_payload": true
}

PUT /notifications.json

Edits your notifications settings. Return Notifications object.

parameters attributes
url url where to send notifications
delay notification delay
send_video_payload send additional payload for video. By default is false
encoding_completed notify when encoding has been completed
encoding_progress notify when encoding started
video_created notify when video has been created
video_encoded notify when all encodings have been completed

API Errors

When there is an issue with a request, Telestream Cloud will return the appropriate HTTP status code, along with a JSON object containing the error name and a message. (500 status returns an empty body). For more information on HTTP status codes, see https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

500 Internal Error

When there is an internal error a 500 status will be returned along with additional information in the message. Whenever a 500 error occurs our technical team is notified of the issue and will investigate the root of the problem immediately. If your experience a recurring issue, please submit a support ticket to our support

Example response

status: 400
{
  "error":"BadRequest",
  "message":"Currently only .json is supported as a format"
}
status: 400
{
  "error":"BadRequest",
  "message":"All required parameters were not supplied: access_key, signature, timestamp"
}

400 Bad Request

This error will be returned in two cases. Either because you have requested a response format that is not supported (currently only JSON is supported, so all urls must end in .json), or you have not submitted all of the required parameters to a method.

Example response

status: 400
{
  "error":"RecordInvalid",
  "message":"Name has already been taken"
}

400 Record Invalid

If the record you have sent is invalid (for example Profile object you have sent) this response will be returned.

Example response

status: 400
{
  "error":"UrlInvalid",
  "message":"The URL is not valid"
}

400 Url Invalid

This error will be returned if the url you have sent to Telestream Cloud was invalid.

Example response

status: 401
{
  "error":"NotAuthorized",
  "message":"Signatures do not match"
}
status: 401
{
  "error":"NotAuthorized",
  "message":"Signatures expired"
}

401 Not Authorized

When the signature parameter of a request is not correct, the server returns a status code 401 and a descriptive message. If you receive this error please ensure that you are constructing and encoding the signature parameter as described in the API Authentication section below.

If you receive a Signatures expired message, that means your clock is out of sync. You can maintain the system time in synchronization with time servers using ntpd.

Example response

status: 401
{
  "error":"S3AccessManagerError",
  "message":"Granting access to s3 bucket failed."
}

401 S3 Access Manager Error

This error will be returned if Telestream Cloud can’t grant access to bucket using provided S3 credentials.

Example response

status: 401
{
  "error":"GCSAccessManagerError",
  "message":"Granting access to GCS bucket failed."
}

401 GCS Access Manager Error

This error will be returned if Telestream Cloud can’t grant access to bucket using provided GCS credentials.

Example response

status: 403
{
  "error":"Forbidden",
  "message":"Account with access key abcdefgh is disabled."
}

403 Forbidden

This error will be returned if you do not have access to requested operation, for example if your account is disabled.

Example response (example)

status: 404
{
  "error":"RecordNotFound",
  "message":"Couldn't find Video with ID=X"
}

404 Record Not Found

A record with the id supplied could not be found.

Example response

status: 413
{
  "error":"FileSizeLimitExceeded",
  "message":"File size limit for this account is set to 10485760 bytes"
}

413 File Size Limit Exceeded

If you attempt to upload a file > 25GB, the following error will be returned.

Example response

status: 415
{
  "error":"FormatNotRecognised",
  "message":"Video data in file not recognized"
}

415 Format Not Recognised

This error will be returned if Telestream Cloud can’t recognize format of the video sent.

Error classes and Error messages

Encoding and Video have 2 special attributes when their status is set to ‘fail’

parameters description
error_class Helps you figure out what happened and what to do next.
error_message Gives you a more descriptive message of the error

The following table lists all possible error classes:

Storage

Telestream Cloud supports multiple storage providers to better suits your needs.

Amazon Simple Storage (S3)

Telestream Cloud uses S3 to store encoded video files so first of all you should signup for an Amazon Web Service account.

Create AWS account

  1. Get Amazon AWS Account

    Go to http://aws.amazon.com and follow the instruction in Sign Up.

  2. Signup for S3

    Once your AWS account has been created, go to Amazon Simple Storage Service (S3) in the management console and sign up for the service.

  3. Grab your credentials

    Go to IAM Users settings (Services -> IAM -> Users) and create a new user for Telestream Cloud. Then copy the generated user credentials (Access Key ID and Secret Access Key, you will later need them to create a Telestream Cloud cloud). Now you will need to give Telestream Cloud permissions to create new clouds and upload files to the newly created user. Find the user in IAM settings and click Attach User Policy. You will have to select appropriate user policy - either choose one of the predefined policies to let Telestream Cloud in (Amazon S3 Full Access, more permissive like Power User Access would work but are not needed), or create a custom policy.

You are now ready to create a Telestream Cloud !

{
  "Version": "2008-10-17",
  "Id": "PandaStreamBucketPolicy",
  "Statement": [
    {
      "Sid": "Stmt1344015889221",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::078992246105:root"
      },
      "Action": [
        "s3:AbortMultipartUpload",
        "s3:GetObjectAcl",
        "s3:DeleteObject",
        "s3:GetObject",
        "s3:PutObjectAcl",
        "s3:ListMultipartUploadParts",
        "s3:PutObject"
      ],
      "Resource": "arn:aws:s3:::YOUR-BUCKET/*"
    },
    {
      "Sid": "Stmt1344015889221",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::078992246105:root"
      },
      "Action": [
        "s3:GetBucketAcl",
        "s3:ListBucket",
        "s3:ListBucketMultipartUploads",
        "s3:GetBucketLocation",
        "s3:PutBucketAcl"
      ],
      "Resource": "arn:aws:s3:::YOUR-BUCKET"
    }
  ]
}

Limit Telestream Cloud’s access on your bucket

By default Telestream Cloud only has access to the bucket. If you want to further restrict what Telestream Cloud can do, you can use a policy file like the one shown below. This example contains the minimum set of operations that Telestream Cloud needs for encoding and management.

In your AWS Console, S3, Properties, there is an “Edit bucket policy” button. Replace “YOUR-BUCKET” in the following text with your bucket name and paste it in the box. When done, you can remove the “telestreamcloud” user in the list and save.

Create an IAM user for Telestream Cloud

If you don’t want to enter your master AWS credentials when creating a new Cloud, here is an alternative method.

NOTE: Telestream Cloud NEVER stores your AWS credentials. We only use them to create, identify and authorise your S3 bucket to be used by Telestream Cloud.

Amazon allows you to create restricted users called IAM. Instead of giving your master AWS credentials you can create an IAM user with just the permissions that Telestream Cloud needs to authorise the bucket and feed these credentials to Telestream Cloud when creating a new Cloud. For more informations on IAM have a look at Amazon’s documentation here: https://console.aws.amazon.com/iam

Policy statement

{
  "Statement": [
    {
      "Sid": "StmtXXXXXXXXX",
      "Action": [
        "s3:GetBucketAcl",
        "s3:GetBucketLocation",
        "s3:PutBucketAcl"
      ],
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::*"
      ]
    }
  ]
}

Create the user

To ensure created user will have sufficient privileges to be used by Telestream Cloud, you need to attach some policies to this user.

IAM step 1

IAM step 2

IAM step 3

Now your user should be ready.

Use LiveSync for your Telestream Cloud factory

With LiveSync every new file added to the S3 source bucket will be automatically encoded to all output profiles selected for this factory. You can set this option in your factory settings in console. Check out our Guides section for more information!

Google Cloud Storage (GCS)

To use Google Cloud Storage with Telestream Cloud, you should sign up for a GCS account to allow Telestream Cloud store encoded video files.

Create GCS account

  1. Go to Google Developers Console and follow the sign up instructions. If you don’t have Google account, you will be prompted to create one.

  2. Once signed in create project that you wish to activate GCS for

  3. Enable Google Cloud Storage service
    while in the project select API’s & AUTH in the left sidebar in the APIs list click button next to Google Cloud Storage to turn it on

  4. In the project Settings click Enable billing and you will be guided through the process

  5. To be able to create buckets in Telestream Cloud you will need your Access Key and Secret

  6. To obtain Access Key & Secret:
    Go to your project’s Storage page and under Cloud Storage select Storage access from the left menu and then click Interoperability tab on top. Now you may need to click Enable Interoperability access button to enable it. When you do it you should see your Access Key & Secret.

You are now ready to create a Telestream Cloud with Google Cloud Storage!

Rackspace Cloud Files (CF)

Before storing encoded video files with Rackspace you should sign-up for an CloudFiles account if you don’t have one yet.

Create CloudFiles account

  1. Get RackSpace account
    Go to Cloud Files page and follow the sign-up process.

  2. Create container (optional)
    Once signed in select Files in top menu and create container (either private or public).

  3. Grab your credentials
    In your Cloud Control Panel you’ll find your username and API key in Account Settings.

  4. Get your Temp URL token
    You can either create Temp URL token yourself through API - see how - or let us generate one for you while creating a new Factory using Rackspace storage.
    You can use the Temporary URL feature (TempURL) to create limited-time Internet addresses that allow limited access to your Cloud Files account. Using TempURL, you can allow others to retrieve objects from or place objects in your Cloud Files account for a specified amount of time. After the specified amount of time expires, access to the account with the TempURL is denied.

You are now ready to create a Telestream Cloud !

FTP Storage (FTP)

If you prefer using your own infrastructure you may set up Telestream Cloud to store encoded files on FTP server.

Setting up FTP with Telestream Cloud

  1. Log in to your Telestream Cloud account

  2. Click Add New on your dashboard
    In Create New Factory form select FTP Server as storage option

  3. Enter your credentials
    Assuming you already have FTP account prepared, just enter host, port (default 21), username, pass and define folder where the files should be stored.

Your Factory with FTP storage is ready to use!

Aspera Enterprise Server Storage (FASP)

If you prefer using your own infrastructure you may set up Telestream Cloud to store encoded files on your Aspera Enterprise Server.

Setting up FASP with Telestream Cloud

  1. Log in to your Telestream Cloud account

  2. Click Add Factory on your dashboard
    In Storage Options form select Aspera Enterprise Server

  3. Enter your credentials
    Enter host, username, password and bucket or folder where the files should be stored.

Your Factory with Aspera Enterprise Server storage is ready to use!

Profiles

Presets

Encoding profile presets

Telestream Cloud provides several encoding profile presets which make it easy to setup the correct output formats for your videos.

To manage your profiles

  1. Log into your Telestream Cloud Dashboard
  2. Select your Factory
  3. Click on the Profiles Tab
  4. Click Add profile and you’ll be able to select from one of the recommended presets.


Encoding profiles

Available presets

Below you’ll find details about the presets available:

MP4 (H.265)

H.265 video with AAC audio for playback on HTML5 browsers, desktop players, Flash, Apple iPhone (3GS and above) and iPad. Currently it’s premium feature.

parameter standard quality
preset_name h265
audio bitrate 128kbps (by default)
resolution 640x480 (by default)

MP4 (H.264)

H.264 video with AAC audio for playback on HTML5 browsers, desktop players, Flash, iPhone (3GS and above) and iPad. Use H264 baseline to support most of phones like first Apple iPhone’s and Blackberry’s.

parameter standard quality
preset_name h264
audio bitrate 128kbps (by default)
resolution 640x480 (by default)

WebM (VP8)

VP8 video with Ogg Vorbis audio for playback in HTML5 compatible browsers.

paramater standard quality
preset_name webm
audio bitrate 128kbps (by default)
resolution 640x480 (by default)

OGG (Theora)

Theora video with Ogg Vorbis audio for playback in HTML5 compatible browsers.

parameter standard quality
preset_name ogg
audio bitrate 128kbps (by default)
resolution 640x480 (by default)

HTTP Live Streaming (iOS Adaptive Streaming)

# Sub streams
TelestreamCloud::Profile.create!(
  :name => "hls.iphone.400k",
  :preset_name => "hls.variant",
  :video_bitrate => 400
)
TelestreamCloud::Profile.create!(
  :name => "hls.iphone.600k",
  :preset_name => "hls.variant",
  :video_bitrate => 600
)
TelestreamCloud::Profile.create!(
  :name => "hls.ipad.1200k",
  :preset_name => "hls.variant",
  :video_bitrate => 1200
)
TelestreamCloud::Profile.create!(
  :name => "hls.audio",
  :preset_name => "hls.variant.audio",
)

# iPhone and iPad Playlist
TelestreamCloud::Profile.create!(
  :name => "iphone",
  :preset_name => "hls.variant.playlist",
  :variants => "hls.iphone*,hls.audio",
  :extname => ".tar"
)
TelestreamCloud::Profile.create!(
  :name => "ipad",
  :preset_name => "hls.variant.playlist",
  :variants => "hls.iphone*,hls.ipad*,hls.audio",
  :extname => ".tar"
)

Special multi-bitrate segmented video for streaming to Apple devices.

Create a Master playlist profile that will list all sub-streams into one file.

parameter HLS playlist HLS variants
preset_name hls.variant.playlist hls.variant

Then create a profile for each sub-stream of your Master Playlist. Each profile sub-stream (EXT-X-STREAM-INF) contains RESOLUTION, BANDWIDTH tags to help the client to choose an appropriate stream.

iOS devices will stream the best variant depending on the quality of the network connection. See Apple’s recommendation for more details.

You can create different playlists (one for iPhone one for iPad). Only the profiles with their names matching the variant attribute will be added to the playlist.

(new) Create .tar file

parameter attributes
extname Setting extname to .tar for the playlist profile will create a .tar file that contain all variants that match HLS master playlist format instead of creating separate file for each variant.

We strongly recommend sending the video object with full list of profiles at once.

There is another way to do so by adding encodings to video previously sent (by POST /encodings.json) - if you prefer this approach then you need to remember to send the playlist file first! If you mess up the order, you may receive NoFilesToUpload : Files list for upload is empty error.

(new) AES-128 encryption

It is possible to ecrypt video using AES-128. More info in our guides.

MPEG DASH

MPEG standard HTTP based adaptive bitrate streaming solution (supported by YouTube, Netflix).

parameter MPEG DASH playlist MPEG DASH variants
preset_name dash.variant.playlist dash.variant

(new) Create .tar file

parameter attributes
extname Setting extname to .tar for the playlist profile will create a .tar file that contain all variants that match HLS master playlist format instead of creating separate file for each variant.

We strongly recommend sending the video object with full list of profiles at once.

There is another way to do so by adding encodings to video previously sent (by POST /encodings.json) - if you prefer this approach then you need to remember to send the playlist file first! If you mess up the order, you may receive NoFilesToUpload : Files list for upload is empty error.

(new) Common Encryption (CENC)

CENC is now available for DASH. More info here.

MP3

MP3 audio preset.

parameter MP3
preset_name mp3
audio bitrate 192kbps (by default)

M4A (AAC)

MP4 audio preset.

parameter M4A (AAC)
preset_name aac
audio bitrate 192kbps (by default)

OGA (Vorbis)

Ogg Vorbis audio preset.

parameter OGA (Vorbis)
preset_name vorbis
audio bitrate 192kbps (by default)

Thumbnail

Special preset for creating thumbnails from video.

parameter Thumbnail
preset_name thumbnail

Ruby example

TelestreamCloud::Profile.create!(
  :preset_name => "h264", # A valid preset name, as per the tables above
  :name => "my-h264", # Unique name for this profile
  :h264_crf => 23,
  :h264_profile => "baseline",
  :h264_level => "3.0",
  :width => "480",
  :height => "320"
)

Add an H264 profile

Telestream Cloud gives you complete control of presets using the API and the available libraries. For this, simply pass the preset_name attribute instead of the command attribute.

Ruby example

TelestreamCloud::Profile.create!(
  :name => "h264",
  :preset_name => "h264",
  :width => 480,
  :height => 320,
  :watermark_url => "http://www.pandastream.com/images/panda_logo.png",
  :watermark_bottom => 5,
  :watermark_right => 5
)

Add Watermarking

You may want to add watermarking to your encodings. Use the api to set the url and the position of a remote image to use as a watermark.

Ruby example

TelestreamCloud::Profile.create!(
  :preset_name => "h264",
  ....
  :frame_count => 5
)

Create Thumbnails

You have two ways of creating thumbnails.

Screenshots will be generated and uploaded to the S3 bucket with the name using the following convention: $path$_$screenshot_number$.jpg e.g. (my-path/2f8760b7e0d4c7dbe609b5872be9bc3b_4.jpg).

Ruby example

TelestreamCloud::Profile.create!(
  :preset_name => "thumbnail",
  ....
  :extname => '.jpg', # or .png
  :frame_interval => "300f",
  :width => 90,
  :height => 60,
)

The resulting encoding will have all the thumbnails listed inside the files attribute

Ruby example

TelestreamCloud::Profile.create!(
  # h264 profile
  :preset_name => "h264",

  # sets your profile name to h264
  :name => "h264",

  # 2 pass encoding
  :two_pass => true,

  # 30 fps
  :fps => 30,

  # mp4 format and .mp4 extname
  :extname => ".mp4"

  # 48k sample rate
  :audio_sample_rate => 48000,

  # Resolution 1080x720
  :height => 720,
  :width => 1080,

  # set the s3 destination
  :path_format => "my/path/:id",

  # don't upscale the video if the input is smaller than your profile resolution
  :upscale => false,

  # starts the clip after 10 seconds
  :clip_offset => "00:00:10",

  # Cut the clip after 20 minutes
  :clip_length => "00:20:00",

  # Keep aspect ratio
  :aspect_mode => 'letterbox',

  # Bitrates
  :video_bitrate => 2200,
  :audio_bitrate => 128,
)

Complete settings

You can set numerous of options to make your encoding just right.

FFmpeg Neckbeard

Telestream Cloud provides complete control over the commands used to convert video. You can log in to your Telestream Cloud Dashboard and choose from our presets, or you can use the API to access the bare metal.

Stacks

As ffmpeg API changes, we can’t always update ffmpeg without breaking your commands. That’s where presets become handy. To make sure your commands are backward compatible with the encoding API and ffmpeg’s API, we are using separate stacks of tools. The default stack is corepack-1. There is also corepack-2 and corepack-3. Corepack-1 will be deprecated soon and replaced by corepack-2. However, all profiles created with the previous stack will continue to work.

If you use API to create your profiles and want to stay on the old stack, make sure you specify ‘stack’ => 'corepack-1’. You can find the 'corepack-1’ docs here

We highly recommend to switch to presets or to the newest stack (corepack-3). It improves encoding/decoding speed and formats/codecs support.

API

All of the fields below are required when creating an advanced profile.

parameters attributes
extname File extension, beginning with ’.’, of the output video.
command Video conversion command (in most cases an ffmpeg command).
name Which is a unique name inside your Factory to reference your profile.

Telestream Cloud provides full access to a suite of powerful video conversion tools. These tools can be used together in one profile to output a variety of formats.

To execute multiple commands in one profile, you must separate each with a \n (newline) or ; (semicolon).

Telestream Cloud provides a few api tokens you can use in your commands:

parameters attributes
$input_file$ input filename
$output_file$ output filename
$width$ width defined in your profile
$height$ height defined in your profile
$record_id$ encoding ID
$filters$ scale your video considering the aspect mode and resolution attributes of your profile.
$audio_sample_rate$ audio sample rate
$audio_channels$ audio channels (default is copy)
$audio_bitrate$ audio_bitrate
$video_quality$ video bitrate or h264 crf
$video_bitrate$ video_bitrate only
$max_audio_bitrate$ audio bitrate threshold
$max_video_bitrate$ video bitrate threshold
$fps$ frame rate (default is copy)
$clip$ subset of the video to be encoded

Examples

Ruby example

TelestreamCloud::Profile.create!(
  :stack => "corepack-3",
  :name => "h264.SD",
  :width => 480,
  :height => 320,
  :h264_crf => 23,
  :audio_bitrate => 128,
  :extname => ".mp4",
  :audio_sample_rate => 44100,
  :keyframe_interval => 250,
  :command => "ffmpeg -i $input_file$ -threads 0 -c:a libfaac -c:v libx264 -preset medium $video_quality$ $audio_bitrate$ $audio_sample_rate$ $keyframes$ $fps$ -y video_tmp_noqt.mp4\nqt-faststart video_tmp_noqt.mp4 $output_file$"
)

PHP example

<?php
$panda->post('/profiles.json', array(
    'stack' => "corepack-3",
    'name' => "h264.SD",
    'width' => 480,
    'height' => 320,
    'h264_crf' => 23,
    'audio_bitrate' => 128,
    'extname' => ".mp4",
    'audio_sample_rate' => 44100,
    'keyframe_interval' => 250,
    'command' => 'ffmpeg -i $input_file$ -threads 0 -c:a libfaac -c:v libx264 -preset medium $video_quality$ $audio_bitrate$ $audio_sample_rate$ $keyframes$ $fps$ -y video_tmp_noqt.mp4\nqt-faststart video_tmp_noqt.mp4 $output_file$'
));
?>

Let’s create a custom h.264 profile.

You may not find a preset for your exactly need but the following examples should help you to encode videos into some popular formats.

FLV
TelestreamCloud::Profile.create!(
  :stack => "corepack-3",
  :name => "flv",
  :width => 480,
  :height => 320,
  :video_bitrate => 500,
  :audio_bitrate => 128,
  :extname => ".flv",
  :command => "ffmpeg -i $input_file$ -threads 0 $audio_sample_rate$ $video_bitrate$ $audio_bitrate$ $fps$ $filters$ -y $output_file$"
)
AVI
TelestreamCloud::Profile.create!(
  :stack => "corepack-3",
  :name => "avi",
  :width => 480,
  :height => 320,
  :video_bitrate => 500,
  :audio_bitrate => 128,
  :extname => ".avi",
  :command => "ffmpeg -i $input_file$ -threads 0 -c:v msmpeg4 -c:a libmp3lame -tag:v MP43 $audio_sample_rate$ $audio_sample_rate$ $video_bitrate$ $audio_bitrate$ $fps$ $filters$ -y $output_file$"
)
WMV
TelestreamCloud::Profile.create!(
  :stack => "corepack-3",
  :name => "wmv",
  :width => 480,
  :height => 320,
  :video_bitrate => 500,
  :audio_bitrate => 128,
  :extname => ".wmv",
  :command => "ffmpeg -i $input_file$ -threads 0 -c:v wmv2 -c:a wmav2 $audio_sample_rate$ $video_bitrate$ $audio_bitrate$ $fps$ $filters$ -y $output_file$"
)
OGG - 2 pass
TelestreamCloud::Profile.create!(
    :stack => "corepack-3",
    :name => "ogg.2pass",
    :width => 480,
    :height => 320,
    :video_bitrate => 500,
    :audio_bitrate => 128,
    :extname => ".ogg",
    :command => "ffmpeg -i $input_file$ -f ogg -pass 1 -threads 0 -c:v libtheora -c:a libvorbis $audio_sample_rate$ $video_bitrate$ $audio_bitrate$ $fps$ $filters$ -y /dev/null\nffmpeg -i $input_file$ -f ogg -pass 2 -threads 0 -c:v libtheora -c:a libvorbis $audio_sample_rate$ $video_bitrate$ $audio_bitrate$ $fps$ $filters$ -y $output_file$"
  )

Our presets support two pass encoding but if you need the command, here is the way to do it:

Available conversion tools

Here is the list of conversion tools available in Telestream Cloud.

FFmpeg

See http://ffmpeg.org

FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.

We provide a recent version of ffmpeg, compiled from the git repository with as many codecs as we could get our hands on (See full list of Supported File Formats and Codecs).

command name: ffmpeg
command version: Ffmpeg 0.10

Lame

See http://lame.sourceforge.net/

LAME is a high quality MPEG Audio Layer III (MP3) encoder.

command name: lame
command version: Lame 3.99

MEncoder

See http://www.mplayerhq.hu/

An other video encoder built from the same code as MPlayer.

command name: mencoder

Segmenter

Segmenter divides input file into smaller parts for HLS playlists.

command name: segmenter

Manifester

Manifester is a tool to create m3u8 manifest file.

command name: manifester

QtFaststart

See http://multimedia.cx/eggs/improving-qt-faststart/

Moves the moov atom in front of the data to improve network streaming.

command name: qt-faststart

QtRotate

See https://github.com/danielgtaylor/qtrotate

QtRotate is a tool to work with rotated files.

command name: qtrotate

Yamdi

See http://yamdi.sourceforge.net/

Yamdi is a metadata injector for FLV files.

command name: yamdi

MP4Box

See http://gpac.wp.mines-telecom.fr/mp4box/

Mp4Box is a tool for manipulating multimedia files.

command name: MP4Box

Telestream Cloud Uploader

The Telestream Cloud uploader allows you to upload videos from your web application to Telestream Cloud. It’s an HTML5 uploader solution with Flash fallback.

Javascript Uploader

What’s new

Here is a couple of features that forced us to rewrite the uploader from scratch.

  1. Library agnostic.
  2. Better code base and a better api.
  3. Resumable uploader. We built a new upload backend to handle the resume of your upload if you go offline. This is great for big files.
  4. Upload queueing. You can easily add multiple videos on a single page.
  5. Consistent UI between HTML5 and FLASH.

Upload Strategies

The Telestream Cloud Uploader will use HTML5 upload if the browser supports it, and will fall back to Flash upload if necessary. Flash doesn’t have resumable capabilities and will upload your content as a MultiPart stream.

Browser Upload Supported? Method Used
Opera Yes HTML5
Safari Yes HTML5
Chrome Yes HTML5
Firefox >= 3.5 Yes HTML5
IE 6-9 Yes Flash
Others Yes Flash

Library installation

In order to start using the uploader, you need to paste the link to the CDN hosted minified version of the uploader library. You can keep up to date automatically with patch releases by linking to a minor version. The current stable version is 2.3. To do so, simply include the following declaration in your page:

<script src="//cdn.pandastream.com/u/2.3/panda-uploader.min.js"></script>

Initialization

By invoking panda.uploader.init(options) with a set of configuration options, you will initialize the Telestream Cloud uploader

Here is the list of options available at the time of initialization:

parameters attributes
buttonId Dom Id of the styled Browsing button.
( required!, it should be a <div> )
authorizeUrl Route of the authentication request.
( example: /panda/authorize_upload )
autoStart Upload starts right after the user select a file.
( true/false, default: true )
autoResume Automatically resume the upload after you went offline.
( true/false, default: true )
resumeInterval Interval in milliseconds before the upload gets resumed.
( default: 5000 )
allowSelectMultipleFiles Allows you to add multiple files to the upload queue.
( true/false, default: false )
progressBarId Dom id of the progress bar.
fileDropId Dom id of the file drop zone.
fileUrlInputId Dom id of the text input where url will be placed.
fileUrlButtonId Dom id of submit button for fileUrlInputId.
maxFileSize Maximun file size.
( example: ‘10 MB’, valid: [K|M|G]B, default: null )
confirmBeforeUnload Alert the user that an upload is processing.
( true/false, default: true )
type Forces the uploader type.
( html/flash, default null )
onQueue (files) List of <files> added to the Queue.
onStart (file) <file> starts uploading.
onProgress (file, percent) <file> upload progress.
onSuccess (file, json) The uploader has successfully uploaded <file> and returned a <json> object.
onError (file, text) The uploader has failed uploading <file> and returned a response.
onComplete () The upload queue has been completed.
onCancel (file) <file> upload has been canceled.
onPause (file) <file> upload has been paused due to connectivity issues.

<Uploader> Object:

parameters attributes
type Returns the uploader type (html5/flash).
setPayload (file, object) Add extra variables to the payload.
setEnabled (bool) Enable/Disable the uploader.
getQueuedFiles () Returns the list of queued files.
start () Start uploading next queued file.
cancel (file) cancel <file> upload.

<File> Objet:

parameters attributes
name File name.
size File size in Bytes.

Upload authentication

Ruby example

# Using Rails and https://github.com/Telestream/telestream-cloud-ruby-sdk
# app/controllers/panda_controller.rb
class PandaController < ApplicationController
  def authorize_upload
    payload = JSON.parse(params['payload'])

    options = {
      profiles: "h264,webm",
      # payload: 'something',
      # path_format: ':video_id/:profile/play',
    }
    if payload['filename']
      url = '/videos/upload.json'
      options['file_name'] = payload['filename']
      options['file_size'] = payload['filesize']
    else
      url = "/videos.json"
      options['source_url'] = payload['fileurl']
    end

    upload = Panda.post(url, options)

    render :json => {:upload_url => upload['location']}
  end
end

Python example

# Using Django and https://github.com/Telestream/telestream-cloud-python-sdk
# views.py
@csrf_exempt
def authorize_upload(request):
  params = json.loads(request.POST['payload'])

  options = {"profiles": "h264"}
  if params["filename"]:
    url = "/videos/upload.json"
    options["file_name"] = params["filename"]
    options["file_size"] = params["filesize"]
  else:
    url = "/videos.json"
    options["source_url"] = payload["fileurl"]

  upload = panda.post(url, options)

  auth = {"upload_url": json.loads(upload)["location"]}
  return HttpResponse(json.dumps(auth), mimetype='application/json')

PHP example

<?php
// authorize_upload.php
$payload = json_decode($_POST['payload']);

$filename = $payload->{'filename'};
$filesize = $payload->{'filesize'};
$fileurl = $payload->{'fileurl'};

$options = array('profiles' => 'h264');
if ($filename) {
  $url = '/videos/upload.json';
  $options['file_name'] => $filename;
  $options['file_size'] => $filesize;
} else {
  $url = '/videos.json';
  $options['source_url'] => $fileurl;
}

$upload = json_decode(@$panda->post($url, $options);

$response = array('upload_url' => $upload->location);

header('Content-Type: application/json');
echo json_encode($response);
?>

The authentication of your new upload occurs via an HTTP Request to a configurable authentication url when the file is ready to be uploaded. In the JavaScript Uploader the HTTP Request is executed via AJAX POST request. The destination of the authentication request can be configured by setting the authorizeUrl param when calling panda.uploader.init.

The default is /panda/authorize_upload

A payload is then sent as a JSON encoded object in the body and can contain 2 sets of variables:

  1. filesize, filename, content_type
  2. fileurl

These should be self-explanatory.

The api request to Telestream Cloud should include: for /videos/upload.json endpoint file_name and file_size for /videos.json endpoint source_url

Optionally, you can set:

parameters attributes
use_all_profiles: (true / false) Default is false
profiles: Comma-separated list of profile names.
By default no encodings are created yet.
payload: Arbitrary string stored along the Video object.
path_format: Allows you to set the location inside your S3 Bucket.
It should not include the file extention.

More details on the api docs

The generated JSON should include:

parameters attributes
upload_url Location where to upload the file
postprocess_url (optional) When a file upload is complete, a request is made to this url to let your server know that the uploader finished uploading the file

Simplest example

<form action="/path/to/action" id="new_video" method="POST">

  <input type="hidden" name="panda_video_id"/>

  <div id="browse-files">Choose file</div>

</form>

Uploader setup

var upl = panda.uploader.init({
  'buttonId': 'browse-files',
  'onProgress': function(file, percent) {
    console.log("progress", percent, "%");
  },
  'onSuccess': function(file, data) {
    $("#new_video")
      .find("[name=panda_video_id]")
        .val(data.id)
      .end()
      .submit();
  },
  'onError': function(file, message) {
    console.log("error", message);
  },
});

The following is the simplest working form that will upload a video:

In this example:

  1. Click on “Choose file”. You will be shown a file selection dialog.
  2. Select a file to upload.
  3. Wait for the upload to complete.
  4. After the upload completes, Telestream Cloud returns a unique ID that identifies your video. The form will finally be submitted so that your application can read this value and use it to reference the video later on.
var upl = panda.uploader.init({
  ...
  'onQueue': function(files) {
    $.each(files, function(i, file) {
      upl.setPayload(file, {'authenticity_token': AUTH_TOKEN});
    })
  },
}

If you need to, you can add some extra data to the payload alongside the ones mentioned above.

Additional features

Progress Bar and File Drop

<form action="/path/to/action" id="new_video" method="POST">

  <input type="hidden" name="panda_video_id"/>

  <div class='progress'><span id="progress-bar" class='bar'></span></div>

  <div id="file-drop">Drop files here</div>

  <div id="browse-files">Choose file</div>

</form>

Uploader setup

var upl = panda.uploader.init({
  ...
  'progressBarId': "progress-bar",
  'fileDropId': "file-drop",
});

The uploader comes with some handy handlers like Progress Bars and File Drop.

The uploader doesn’t come with any styling. Take a look at Twitter Bootstrap.

Resume an upload

var upl = panda.uploader.init({
  ...
  'autoResume': false,
  'onPause': function(){
    $("#notice").text("You went offline.");
  }
})

$("#resume-btn").click(function() {
  upl.start();
})

If you have been disconnected from the Internet while you were uploading a file you will be notified by the onPause callback. It’s important to note that the Flash uploader doesn’t support this feature so the upload will fail.

By default, the uploader will setup a resume interval of 5 seconds.

You can also create a resume button.

To resume your uploading queue, just call the start method and your current upload will continue where it left off.

Abort an upload

$("#cancel-btn").click(function() {
  upl.cancel(file);
})

If you want to abort an upload that is currently taking place, use the cancel() function from the uploader instance:

An aborted upload is no longer resumable.

Upload file from another server

<form action="/path/to/action" id="new_video" method="POST">

  <input type="hidden" name="panda_video_id"/>

  <input id="file-url" type="text" placeholder="Type URL to file">
  <button id="file-url-send" type="button">Upload from URL</button>

  <div id="browse-files">Choose file</div>

</form>

Uploader setup

var upl = panda.uploader.init({
  ...
  'fileUrlInputId': "file-url"
  'fileUrlButtonId': "file-url-send"
});

You can also upload any publicly available video file just by submitting the URL of it.

Upload from URL in pure JavaScript

var upl = panda.uploader.init({
  ...
});

upl.uploadFromUrl("http://mysite/video.mp4", function (error) {
  // If something went wrong the error parameter will be passed to this callback function.
  // If error is undefined it means action ended with success.
});

You can also omit the HTML form part, and just call uploader method uploadFromUrl to achieve the same effect.

Ruby example

# app/controllers/panda_controller.rb
class PandaController < ApplicationController
  def authorize_upload
    ...
    render :json => {
      :upload_url => upload['location'],
      :postprocess_url => '/some/postprocess'
    }
  end
end

Python example

# views.py
def authorize_upload(request):
  ...
  auth = {
    "upload_url": json.loads(upload)["location"],
    "postprocess_url": '/some/postprocess',
  }

  return HttpResponse(json.dumps(auth), mimetype='application/json')

PHP example

<?php
// authorize_upload.php
$response = array(
  'upload_url' => $upload->location},
  'postprocess_url' => 'postprocess.php'
  );

header('Content-Type: application/json');
echo json_encode($response);
?>

Post processing

You might want to let your server know that the uploader finished uploading a file. This is quite useful when handling multiple uploads on a single web page.

To achieve this, you simply need to return the postprocess_url during the authentication handshake.

Ruby example

# app/controllers/some_controller.rb
class SomeController < ApplicationController
  def postprocess
    response = JSON.parse(params["upload_response"])
    render :json => { :id => "some-id" }
  end
end

Python example

# views.py
@csrf_exempt
def postprocess(request):
  response = json.loads(request.POST['upload_response'])
  return HttpResponse(json.dumps({"id": "some-id"}), mimetype='application/json')

PHP example

<?php
// postprocess.php

$response = json_decode($_POST['upload_response']);
header('Content-Type: application/json');
echo json_encode(array('id' => 'some-id'));
?>

Once the video is successfully uploaded to Telestream Cloud, your server will receive a POST request like this.

var upl = panda.uploader.init({
  ...
  'onSuccess': function(file, data) {
    console.log(data['id']); // 'some-id'
  }
})

The onSuccess callback will expose the data received from the postprocess request.

Guides

LiveSync

Use LiveSync for your Telestream Cloud factory

With LiveSync every new file added to the S3 source bucket will be automatically encoded to all output profiles selected for this factory. Thanks to this, we are handling all the dirty work for you – that means you don’t have to write a single line of code or worry about API calls! You can set this option in your factory settings in console:

Use LiveSync

You also might want to encode all files that are currently stored in this bucket. In order to do that, all you need to do is select Synchronize existing files option. Simple as that.

You can always enable LiveSync at any time for currently existing factory or when creating a new one.

However, here are some important things that you should know about this feature:

LiveSync feature is currently available on AWS only, but we are planning to implement such improvement for those using Google Cloud Storage as well.

Upload API

Streaming upload using client libraries

# https://github.com/Telestream/telestream-cloud-python-sdk#resumable-uploads
us = factory.upload_session("file.mp4", profiles="webm")

retry_count = 0
try:
    us.start()
except Exception as e:
    while retry_count < 5 and us.status != "success":
        try:
            time.sleep(5)            
            us.resume()
        except Exception as e:
            retry_count += 1
# https://github.com/Telestream/telestream-cloud-ruby-sdk/#resumable-upload
us = TelestreamCloud::UploadSession.new("panda.mp4", profiles: "webm")

retry_count = 0
begin
  us.start()
rescue Exception => e
  while retry_count < 5 and us.status != "success"
    begin
      sleep(5)
      us.resume()
    rescue Exception => e
      retry_count += 1
    end
  end
end

Small multimedia files can be sent using POST request on “/videos.json” API endpoint. This will attempt to send te entire using a single request. The obvious drawback of this approach is lack of rich uploading features. You cannot stop and retry the process and in case of a connection failure you have to send the file from the beggining. That’s why it’s usually better for such files to use resumable upload features, which allows you to send files in chunks. If the connection fails, you can query Telestream Cloud for the range of file that has been succesfully sent so you can resume the process from that point onwards.

Telestream Cloud’s Upload API supports 2 ways of uploading a file: resumable (also known as streaming) and multipart upload. The first is a better choice when your environment allows you to do so. The seconds is the standard method for web browsers to send large files. Recent browsers now supports the first method too. Both methods are described in this document.

Instead of creating your own code, you can use session creating functionality offered by the Telestream Cloud libraries.

Create an upload session

->
POST /videos/upload.json
Host: api-us-east.cloud.telestream.net
--
file_size     :     integer
file_name     :     string

<-
Status Code 201

"id"          :     integer
"location"    :     location to upload the video

Before uploading a new file, you need to create an upload session. This is normally done by making an ajax call request from your javascript uploader (with the file size and name) to your backend. The ajax request should return the location for the upload.

At this point, Telestream Cloud gives you a unique resource location to upload the file.

File upload using Streaming method

Protocol

->
PUT /<location>
"Content-Type: application/octet-stream"
"Content-Range: bytes RS-RE/L" [where RS=range start, RE=range end, L=file_size]
--

Body <BINARY>
<-
Status Code 200
--

Body <Video JSON>

If the file has been uploaded successfully, the original request is sent to the backend with the file and you receive the backend’s response. (R2=L-1)

If the Content-Range is missing, the whole file is expected to be sent.

The method can also be POST, as long as the Content-Type is application/octet-stream we can differentiate with the mulitpart upload.

<-
Status Code 204
Range: RS-RE
--

Body <empty>

If the file is incomplete, you get a response that lets you know the missing data (R2<L-1).

Example

->
PUT <location/>
Content-Length: 5
Content-Range: bytes 0-4/9

abcde

<-
Status: 204
Range: 0-4

<empty>

1st chunk:

->
PUT <location/>
Content-Length: 4
Content-Range: bytes 5-8/9

fghi

<-
Status: 200

<{"id":"12345"...}>

2nd Chunk:

Upload status

->
PUT /<location>
"Content-Range: bytes */L"                       [ where L=total file size ]
--

<-
Status Code 204
Range: RS-RE
--

Body <empty>

If the client connection broke, You need to query the server to know where it left the upload. In this case, send an empty request specifying Content-Range: bytes * and Content-Lenght: 0 in the headers.

Abort the upload

->
DELETE /<location>

<-
Status Code 200
--

Body <empty>

File upload using Multipart method

->
POST /<location>
"Content-Type: multipart/form-data"; boundary=---- 
--

Body <BINARY>

<-
Status Code 200
--

Body <Video JSON>

To POST data using an HTML <form> you will have to send the data within the parameter "file".

Client notes

Error handling

The client is expected to retry requests that fail with a status of 5xx or weren’t able to pass through at all. All 4xx errors are errors in the client’s implementation and should be treated accordingly.

Location handling

On each response you may receive a new Location that you need to follow in the subsequent requests. This is to leave us the flexibility of moving the upload to a different host. Please record the new location if it appears to have changed.

Content-Range

Here is the regexp to parse the range header: "^(\d+)-(\d+)$"

Notifications

Rather than polling Telestream Cloud to find when a video has finished encoding, Telestream Cloud allows you to provide a notification endpoint and subscribe to events occurring during the encoding process.

To manage your notifications, log into your Telestream Cloud Dashboard, select your Factory and click on the Notifications tab. Here you’ll be able to specify a url and select events you would like to receive. One you’ve saved your notification settings, notifications will be sent for any new videos and encodings of this Factory.

Events

Telestream Cloud provides the following events:

Ruby example

{
  "event" => "video-created",
  "video_id" => '123234',
  "encoding_ids" => {0 => 'firstid', 1 => 'secondid'}
}

PHP example

$_POST["event"] // => "video-created"
$_POST["video_id"] // => '123234'
$_POST["encodings_ids"][0] // => 'firstid'

video-created

This is called once a video has downloaded (if a url was given), validated, and uploaded to your S3 bucket. The status will either be success or fail. An array of encoding ids is provided, although note that the encodings will not have been processed at this state.

After this notification is sent, a subsequent request can be used to fetch metadata of the input video.

Ruby example

{
  "event" => "video-encoded",
  "video_id" => "bfa6029038de24e4494f20a166700021",
  "encoding_ids" => {0 => 'firstid', 1 => 'secondid'}
}

video-encoded

This is called when all encodings for a video have been completed. Note that this may be returned multiple times if, for example, a new encoding is added for an existing video.

{
  "event" => "encoding-progress",
  "encoding_id" => 'firstid',
  "progress" => 23
}

encoding-progress

This is called approximately every 10s while an encoding is processing, and returns the percentage complete. Use with care since this will generate a lot of traffic!

{
  "event" => "encoding-complete",
  "encoding_id" => "bfa6029038de24e4494f20a166700021"
}

encoding-complete

This is called for each encoding when the encoding is done (or failed).

The post body contains encoding information.

TelestreamCloud::Video.find(params['video_id']).status
=> 'success'

After receiving those IDs you can easily and securely retrieve the state of your videos/encoding by simply using your current library.

Integrate notifications

class TelestreamCloudController < ApplicationController
  def notifications
    if params['event'] == 'video-encoded'
        video = Video.find_by_telestreamcloud_video_id(video_id)
        if video
            UpdateVideoState.perform_async(video.id)
        else
            # might have been deleted
        end
    end
  end
end

class UpdateVideoState
  include Sidekiq::Worker

  def perform(id)
    video = Video.find(id)
    if video.telestreamcloud_video.status == 'fail'
        # video failed to be uploaded to your bucket
    else
        h264e = video.telestreamcloud_video.encodings['h264']
        if h264e.status == 'success'
            # save h264e.url in your models to avoid querying panda each time
        else # handle a failed job
            # h264e.error_class; h264e.error_message
            # a log file has been dumped in your bucket
        end
    end
  end
end

For each event you will receive a POST request, containing the event name (ex: encoding-complete) and some ids the videos or encodings having their status changed, as form data.

Telestream Cloud is expecting a 200 response from you. Otherwise it will retry the notification within an exponential interval of time and during 24 hours. The Initial notification delay field allows to select the initial waiting time in order to manipulate the number and frequency of retried notifications, for example in case of endpoint not being capable of serving large amounts of incoming requests and getting overloaded.

The following example shows a best practice for you to handle those notifications using Async workers. In this example we are going to use Sidekiq to handle async jobs.

Setup in development

Because your development machine is rarely accessible from the Internet, the notifications cannot be sent to you directly. At Telestream Cloud, we use ultrahook to give access to our local development machine to the Internet.

$ gem install ultrahook
# 3000 is the port of the local webserver
$ ultrahook foo 3000
  Authenticated as senvee
  Forwarding activated...
  http://foo.senvee.ultrahook.com -> http://localhost:3000
  1. Create a tunnel
  2. Now set the notification URL in your development Factory to http://foo.senvee.ultrahook.com
  3. Your local app starts receiving notification callbacks

Alternatively, if you just want to see what output Telestream Cloud is producing, create a new target on requestb.in and set it up as the notification end-point. Postbin will record Telestream Cloud’s callbacks and let you see them trough their web interface.

Common Encryption (CENC) - MPEG-DASH

In order to create CENC-encoded DASH videos, you need to send additional parameters when creating a video: cenc_key and cenc_key_id

TelestreamCloud::Video.create!(
   :source_url => "https://storage.googleapis.com/debug_videos/panda.mp4",
   :cenc_key_id => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   :cenc_key => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   )

All tracks are encrypted by default. It is possible to specify whether just audio or video should be encrypted. The following example encrypts just the audio:

TelestreamCloud::Video.create!(
   :source_url => "https://storage.googleapis.com/debug_videos/panda.mp4",
   :cenc_key_id => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   :cenc_key => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   :encrypt_tracks => "audio",
   )

Supported DRMs are Widevine and Playready.

To add Widevine-specific metadata (PSSH box in media files and MPD):

 TelestreamCloud::Video.create!(
   :source_url => "https://storage.googleapis.com/debug_videos/panda.mp4",
   :cenc_key_id => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   :cenc_key => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
   :widevine_provider => "widevine_test",
   :widevine_content_id => "123456",
   )

And the same for Playready:

 TelestreamCloud::Video.create!(
   :source_url => "https://storage.googleapis.com/debug_videos/panda.mp4",
   :cenc_key_id => "9c82ef768d0354c89cd6f1dae8ab647c",
   :cenc_key => "daaa605958a645e39adc3d4009783d2c",
   :playready_server => "http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&UseSimpleNonPersistentLicense=1",
   )

AES-128 encryption for HLS

cipher = OpenSSL::Cipher::AES.new(128, :CBC)
cipher.encrypt
key = cipher.random_key
iv = cipher.random_iv

To use AES-128 HLS encryption, Telestream Cloud will require a 128 bit key, key url and 128 bit initialization vector. If you are willing to use your own key or initialization vector (iv), you can create them yourself.

There are two ways to create encrypted output using Telestream Cloud:

Please note that if you decide to use the second option while the encryption_key and encryption_key_url are set for profile(s), Telestream Cloud will use those specified for the video object.

encoded_key = Base64.encode64(key).chomp
encoded_iv = Base64.encode64(iv).chomp

In order to use your generated key in the profile settings or for the video, you will have to first base64 encode it. Make sure to remove any newline characters at the end.

Profiles pipelining

pipeline = {
  "h264.1" => {},
  "h264.2" => {
    "h264.4" => {},
    "h264.5" => {
      "h264.7" => {}
    }
  },
  "h264.3" => {
    "h264.6" => {}
  }
}


TelestreamCloud::Video.create!(
  :source_url => "SOURCE_URL_TO_FILE",
  :pipeline => pipeline.to_json
)

Profiles pipelining allows you to create connected series, where the output of one profile is also an input of another one.

Telestream Cloud Profiles Pipelining

Image represents example flow of video. Basically, an uploaded video will be encoded with profiles: h264.1, h264.2, h264.3. Then encoding of h264.2 will be used as an input file to process encodings using profiles h264.4 and h264.5, and so on. Telestream Cloud is using JSON to define pipelines structure.

Encodings created using pipelines will have additional field parent_encoding_id which can be used to find out what was the input used to encode or to reproduce pipeline with encodings instead of profiles.

Player

Setting up your video player

Telestream Cloud gives you to flexibility to use the video player which suits you best. There are several great players available, below we explain the benefits of each and how to use them with Telestream Cloud.

HTML5 players

HTML5 is the new standard for embedding videos on the web. The New HTML5 video tag plays video natively in the user’s browser or device. If the browser or device doesn’t support the video tag, several HTML5 video players will automatically fallback to a Flash player.

There is an excellent section in Dive Into HTML5 which explains the new <video> in great detail. You might want to skip to the section about the markup.

There are a few ways to use HTML5 video. In the most basic form you can use a simple <video> tag to embed video. Using this method the video will work with the following:

To support older browsers, you can use a HTML5 video player which supports Flash player fallback. After the next section you’ll find details about several good players which support this.

Basic video tag

Example <video> tag

<video id="movie" width="320" height="240" preload="none"
  poster="http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID_4.jpg" controls>
  <source src="http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID.mp4" type="video/mp4">
  <source src="http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID.ogg" type="video/ogg">
</video>

To support HTML5 video in most browsers there must be H.264 and OGG Theora versions of your videos (Firefox does not have support for H.264 and requires OGG Theora).

To enable H.264 (MP4) and Theora (OGG) in Telestream Cloud, simply head to your account, edit one of your encoding Factories and add enable them as presets. Once this is done, all videos uploaded will be encoded to these formats. See the Encoding Presets docs for more details about managing presets.

The simplest way to then embed your videos is using a basic <video> tag.

In the example you would need to replace VIDEO_ID with the ID of the video from Telestream Cloud, and then the YOUR_S3_BUCKET with the name of your S3 bucket.

JW Player for HTML5

There is now a HTML5 version of this popular player. JW Player for HTML5 supports theming and automatically falls back to the Flash version the browser doesn’t support HTML5 video. Full details about the player are here. The best place to start is by downloading the player and then reading the Embedding The Player instructions. Make sure you read the Multiple Sources section to see how to specify multiple formats.

Below is an example of embedding the player using Telestream Cloud:

<script type="text/javascript" src="/scripts/jquery.js"></script>
<script type="text/javascript" src="/scripts/jquery.jwplayer.js"></script>

First, place this code in the <head> of your page:

<video width="320" height="240" id="player" poster="http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID_4.jpg">
  <source src="http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID.mp4" type="video/mp4">
  <source src="http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID.ogv" type="video/ogg">
</video>

<script type="text/javascript">
  $('#player').jwplayer({
    flashplayer:'/files/player.swf',
    skin:'/files/skins/five/five.xml'
  });
</script>

Second, place this code where you want the video to appear:

FlareVideo

The FlareVideo a great HTML5 video player which has theming support with a seamless fallback to Flash.

Video JS

The Video JS player is another option for displaying HTML5 video. The player is very lightweight and will fallback to the Flash Flowplayer.

Flash Players

Example

<div id='mediaspace'>This text will be replaced</div>

<script type='text/javascript'>
  var so = new SWFObject('/player.swf','mpl',"VIDEO_WIDTH","VIDEO_HEIGHT",'9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('file',"http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID.mp4");
  so.addVariable('image',"http://s3.amazonaws.com/YOUR_S3_BUCKET/ENCODING_ID_4.jpg");
  so.write('mediaspace');
</script>

Using a Flash video player is currently the most reliable way to embed video, and also allows you to easily add in advertising and other interactive features.

There are several options including JW Player and Flowplayer. The instructions below are for using JW Player.

First Download JW Player 5.1, unzip and copy player.swf swfobject.js and to you public directory.

You can keep the same controller code as above.

In your view insert your video player as the example shows.

Streaming

Video streaming with Amazon CloudFront

Assuming you are building a high-traffic website, you will want to have your videos streamed efficiently to your users. After encoding your videos with Telestream Cloud, you can stream them through a content delivery network.

By choosing to streaming your videos, users can skip to any point in the video without having to first wait for it to be downloaded as is the case with progressive download delivery.

You will already have an Amazon Web Services account account if you’ve signed up the S3 for storing videos. We recommend using Amazon’s CloudFront CDN.

CloudFront gives you two ways to deliver video content:

The main difference between Streaming and Progressive Download is in how the data is received and stored by the end user.

You can find some documentation on Wikipedia

The document will cover setting up a video streaming. Progressive download is covered by the standard video player integration documentation.

Create a Streaming distribution

Adding Streaming is very easy. Let’s go through all the steps right now.

Amazon CloudFront signin

Amazon CloudFront signin

A new form will appear.

Amazon CloudFront signin

It should look similar to this:

Amazon CloudFront signin

Congrats, you now have a streaming distribution!

Play your videos

Example

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript"> swfobject.registerObject("player", "9.0.0", "/player.swf"); </script>
<object width='320' height='240' id='player'>
   <param name='movie' value='/player.swf'>
   <param name='allowfullscreen' value='true'>
   <param name='allowscriptaccess' value='always'>
   <param name='wmode' value='opaque'>
   <param name='flashvars' value='file=3ff851d2-d467-11de-87a8-00254bb33798.mp4&streamer=rtmp://s2zw4551q289e3.cloudfront.net/cfx/st&provider=rtmp'>
   <embed id='player'
           src='/player.swf'
           width='320'
           height='240'
           bgcolor='#ffffff'
           allowscriptaccess='always'
           allowfullscreen='true'
           flashvars='file=3ff851d2-d467-11de-87a8-00254bb33798.mp4&streamer=rtmp://s2zw4551q289e3.cloudfront.net/cfx/st&provider=rtmp'
    />
</object>

Before you begin streaming video, you will need to make sure you have a compatible encoding profile setup in your Telestream Cloud Factory. CloudFront supports both FLV and MP4 streaming. We highly recommend using MP4 as the quality is far superior.

Telestream Cloud has a handy MP4 preset you can use. Simply head to your Telestream Cloud account and then edit one of your Factories. At the bottom of the page you will see the ‘Add Profile’ button. Click this and choose 'MP4 (H.264)’ (use Hi if you would like extra good quality video), feel free the change the dimensions if desired.

Once you’ve setup this profile, you will want to use the generated encodings with the embed code example below.

To take advantage of true streaming you will need to use a Flash player. JW Player or Flowplayer are both great options.

The example shows embed using RTMP streaming with JW Player.

Before this will work, you will need to change some parameters.

file=filename the filename of the video in your S3 Bucket. Telestream Cloud saves files to your bucket with the following convention: $path$$extname$. Please check the API docs for more information about encodings.

streamer=value where value is the the streaming url: $domain_name$/cfx/st. You can find the Domain Name by logging into the Amazon CloudFront console.

Once you’ve set these parameters correctly you’ll have video being streamed to your users!

Widget

Telestream Cloud Web Widget

Telestream Cloud Web Widget allows you to easily monitor your Factory encoding activity and share this information on your website.

Telestream Cloud Web Widget Telestream Cloud Web Widget Telestream Cloud Web Widget

Data displayed includes original name of the uploaded file, encoding profile name, encoding progress and number of jobs left in encoding queue.

Configuration

To get the widget working, at first you need to enable it in your Factory settings. Once you set Enable Web Widget to Yes, you will be presented with a small code snippet.

Telestream Cloud Web Widget

Copy this code and pase it into your html body. Please also remember to click Save Changes at the bottom of the Factory Settings page.

If at any time you decide that you no longer want Telestream Cloud to sent out widget data, change Enable Web Widget back to No.

Debugging

If you are having trouble with Telestream Cloud integration, those are a few things you can try out before getting in touch with support.

Debug pannel

We provide you with a debug panel for your application which is located in the web app. From here you can check the state of the uploading / encoding / notification processes.

Debug data is not persistent, make sure you have the debug window open in a different tab or window while testing the workflow.

Javascript debug console

Turning on debugging in your JavaScript

Example

PandaUploader.log = function() {
  if (window.console && window.console.log) window.console.log(arguments);
};

To print the activity of the uploader, you can turn on debugging directly in your javascript console (webkit inspector or firebug). After loading the page, paste the example code.

This should create output like the following in your browser (Chrome in this example):

Javascript debug console

Debugging the encoding

There is a couple of reasons why an encoding can fail. To know more about it, use the api and check the error_message/error_class attribute of the video and encoding.

Also you will find a log file in your bucket which tells why the encoding has failed (ENCODING_ID.log).

FAQ

Please read the FAQ before getting in touch with support.

Where next?

If none of these techniques help get in touch with support and we’ll check whether there is a problem we can help you with.

Please make sure the problem hasn’t been already solved by the support team before creating a new ticket.

Please make sure you can provide us a way to find your account, as a Factory ID or an Encoding ID.

Application integration

Rails

Integrating Telestream Cloud with Ruby on Rails

Coming soon! If you want to integrate Telestream Cloud with your Ruby on Rails app using API V2, take a look at documentation for API V2

PHP

Integrating Telestream Cloud with your PHP application

Coming soon! If you want to integrate Telestream Cloud with your PHP app using API V2, take a look at documentation for API V2

Frequently Asked Questions

Videos

Flash is crashing before or after selecting a file.

Please can you check first if it crashes also with swfupload examples (http://demo.swfupload.org/v220/simpledemo/index.php).

If it does not work get in touch with support.

Video resource has status fail. What does this mean?

The status attribute of a video resource is the result of the following process:

A failure can be the result of following problems:

Check attributes error_class and error_message of the response

All my recent uploads are failing now. What’s happening?

You should first check that Telestream Cloud has still permissions to read and write files to your bucket, using Amazon S3 console. You can grant access to Telestream Cloud again by editing your Factory in the web app.

If yes, please get in touch with the support.

If not, use the edit cloud link inside your account, re-type your bucket name and re-enter your amazon credentials.

I can’t find the encoding log file in my bucket

Check first the status of your video by doing GET /videos/:id.json. If the status is fail then look at the “Video Resource has status fail” section

Telestream Cloud uploads temporary files in my bucket. How can I avoid that?

Telestream Cloud will upload all files having a filename starting with the Encoding ID. So make sure you give to your temporary file a name which doesn’t start with $record_id$.

Can I use a different video container?

When you create a profile from a preset, we choose a default container compatible with the video codec. Generally speaking this will suffice for most peoples needs.

If you do want to change container, you can simply update the extname of your profile:

prof = TelestreamCloud::Profile.create!(
    :preset_name => "h264",
    :extname => ".mkv"
)
How do I encode and store my videos in the EU region?

This is handled through your Telestream Cloud account creation and Amazon’s AWS region selection.

When creating a Telestream Cloud account you can opt to have the service based in Amazon’s EU region (please contact us if you wish to move an existing account to the EU region). This will mean that all your videos are uploaded and encoded on our EU servers.

If you are using this option you will also need to make sure the S3 buckets which store you videos are also in the EU region.

What storage backends can I use?

We’re constantly working on adding new storage options.

Currently Telestream Cloud supports following:

If you have valid accounts with any of these service providers you can connect them right away. Or set up your FTP server for full control.

Does Telestream Cloud support resumable uploads?

Yes, file uploader built into Telestream Cloud web UI supports resumable upload. Anytime connection gets broken while you upload a file to Telestream Cloud it will be resumed once it’s restored. No need to upload file again. Please note that resumable upload will not work with Flash version of uploader which is fallback option.

Encodings

Does Telestream Cloud support audio encoding?

Yes, we provide several audio presets or you can check the Advanced profiles section and create your own profiles.

Does Telestream Cloud support multi-pass encoding?

Yes, 2 pass encoding is supported for presets and custom profiles.

I’m using a custom profile and my videos are not scaled

Make sure that your command include the $filters$ variable

Encoding has status fail. What does that mean?

If you have a failing encoding, make sure: * the original video is reachable. * the profile the encoding is using still exists

Check attributes error_class and error_message of the response

If the steps above are correct, then you should check the log file uploaded to your s3 bucket and see why the command has failed.

If you think your video should have been encoded correctly, please get in touch with support and give us the ID of this encoding.

How can I create Audio Encodings?

Telestream Cloud allows you to convert your audio files or video file into a new audio encoding. We provide some simple to use presets such as MP3, AAC or Ogg Vorbis. Creating an audio encoding profile using the Telestream Cloud Ruby Gem would look like this:

profile = TelestreamCloud::Profile.create!(
    :name => 'aac',
    :extname => '.m4a',
)
How can I adjust the speed of my video?

If you want to speed up or slow down your video (perhaps you are doing a Benny Hill'esque chase scene?) you can create a custom profile with an ffmpeg command value similar to this:

ffmpeg -i $input_file$ -vf "setpts=(1/<speed>)*PTS" $output_file$

Where speed is the desired speed of the video. Setting it to 1 would be the normal speed, 2 would be double speed, etc. A complete command using the Telestream Cloud Ruby Gem might look like this:

profile = TelestreamCloud::Profile.create!(
    :name => 'DoubleTime',
    :extname => '.mp4',
    :command => 'ffmpeg -i $input_file$ -vf "setpts=(1/2)*PTS" $output_file$',
    :title => 'DoubeTime'
)

Now, all of your videos will be encoded with a new double speed version.

How can I create a new encoding to an existing video?

If you want to add another profile and re-encode an existing video, this is the way to do it:

new_profile_name='xxx'
video_id= 'xxxx'
video=TelestreamCloud::Video.find video_id
puts "Adding one encoding to #{video.original_filename} using #{new_profile_name}..."
video.encodings.create!(:profile_name => new_profile_name)
What are Telestream Cloud’s Supported Video Formats?

Telestream Cloud supports encoding a wide variety of video formats. Some of the more popular video formats that we support are:

A complete list of all supported video formats is avaiable here.

Why is my audio out of sync?

Unfortunately, automatically detecting and fixing audio can be a tricky process.

We are always working on ways to make our service better, and increase the quality of our encodings, but sometimes issues like audio sync will appear.

In the event that you are experiencing an encoding with audio issues, the best thing to do is just fire us a support ticket and let us know the video that is causing you problems. We’ll review it and do our best to help you out quickly.

How can I remove the black bars around my videos?

If you see black bars around your videos it’s most likely because your profile’s aspect_mode is set to ‘letterbox’.

You can fix this by adjusting your profile. Just update the aspect_mode setting to 'constrain’ and say bye-bye to those pesky black bars.

Can I use a different notification url?

If you are integrating panda into your webapp with WebHooks enabled, you might want to have a different notification url for your Development, Staging and Production setup.

The best solution is to create a different Telestream Cloud Factory for each environment and set a different notification url.

Separating your environments with a different Factory is a Telestream Cloud best practice. It avoids any accidental operations on data in the wrong environment.

Errors

I’m getting an error code 404. What does this mean?

404 means Resource not found. You are trying to access to a resource which doesn’t exist. It can be a video, and encoding, a profile, a preset or trying to connect with a wrong Factory ID.

If you are posting a video, make sure you are not specifying a wrong profile Id

I’m getting an error code 417. What does this mean?

It means you are maybe using the flash uploader behind a proxy server.

I’m getting an error code 413. What does this mean?

It means you have reached the upload file size limit. If you are on free subscription, make sure you choose a file which doesn’t exceed 10MB or upgrade your account to remove this limit.

I’m getting an error code 401. What does this mean?

It means you sent a Bad request. At least one required parameters is missing. Check The API section and look at the required parameters. This is likely to be caused by the signature not being generated correctly.

I’m getting an error code 401 and I have an EU account using panda uploader. What does that mean?

EU and US use difference hosts. You should specify api_host : "api-eu-west.cloud.telestream.net". Check the panda_uploader’s Documentation

Various

How can I restrict content to certain users?

Telestream Cloud uses Cloudfront to deliver content. As such, you can take advantage of Cloudfront’s access control measures to limit which users see your videos. To use this feature you should set your bucket to private, and then follow the instructions in the Amazon Documention to setup CloudFront to best suit your needs:

How can i play my videos in a private Factory?

If you have set your Telestream Cloud Factory to private, all your file will be uploaded to your s3 bucket with private access only:

(headers['x-amz-acl'] = 'private' )

That means that only you (s3 bucket owner) can generate a signed url, with your AWS Key/Secret pair, that temporarily grant access to your users for a certain amount of time. As this feature is not a Telestream Cloud but an S3 specific feature, we let you generate those Signed URL using the framework of your choice.

Using the Telestream Cloud Ruby Gem would look like this:

require 'fog'
require 'telestream_cloud'
# create a connection
connection = Fog::Storage.new({
  :provider                 => 'AWS',
  :aws_secret_access_key    => YOUR_SECRET_ACCESS_KEY,
  :aws_access_key_id        => YOUR_SECRET_ACCESS_KEY_ID
})
# Get infos from telestream cloud
bucket = TelestreamCloud::Factory.all.first.s3_videos_bucket
video = TelestreamCloud::Video.find("your video id")
# Finally, get the signed url
expires_at = Time.now + (5 * 60)
signed_url = connection.directories.get(bucket).files.get_https_url(video_path, expires_at)
Why am I not receiving any WebHooks anymore?

If you don’t receive any webhooks, go the the Debug page in your dashboard and see in realtime your notification activity.

You should see either a green or red log entry giving you more details about what is going on. Your controller might be failing or some authentication (Basic auth) might prevent your application to receive the notifications.

Can I transfer ownership to my own AWS account?

Amazon S3 doesn’t allow an account to change the ownership of a file.

If you want to change the owner inside your S3 Object ACL, the solution is the make a COPY of your files using your own AWS account. It is described here.

Can I switch to a different encoding provider?

For now you can use either AWS or Google Compute to encode your videos. You can switch between then AWS US, AWS EU and Google US.

When changing encoding provider you should be aware of couple things:

Where is my Telestream Cloud Invoice?

When you sign up with Telestream Cloud, you should receive an email invoice at the email address you registered with. Always make sure to check your Spam / Junk email folders to make sure that your invoice hasn’t gone astray and wandered in there!

If, for some reason, your invoice appears to have completely disappeared on you, please open a support ticket and we will re-send the invoice(s) that you need.

How can I restrict content to certain users?

Telestream Cloud uses Cloudfront to deliver content. As such, you can take advantage of Cloudfront’s access control measures to limit which users see your videos.

To use this feature you should set your bucket to private, and then follow the instructions in the Amazon Documention to setup CloudFront to best suit your needs:

Can I stream MP4 by moving the MOOV atom?

If you are using our presets, we automatically move the MOOV atom to the beginning of your video files. This ensures your videos playback starts fast.

If you are using custom commands, you will need to apply qt-faststart on your files.

Using the Ruby gem:

TelestreamCloud::Profile.create!(
  :stack => "corepack-2",
  :name => "h264.SD",
  :width => 480,
  :height => 320,
  :command => "ffmpeg -i $input_file$ -threads 0 -c:a libfaac -c:v libx264 -preset medium $video_quality$ $audio_bitrate$ $audio_sample_rate$ $keyframes$ $fps$ -y video_tmp_noqt.mp4\nqt-faststart video_tmp_noqt.mp4 $output_file$"
)

Note that we are first saving the video to a file named video_tmp_noqt.mp4. Then qt-faststart is run using the tmp video as input and outputting to your desired output_file.