HeyWatch’s video encoding API allows you to easily integrate our video encoding service in your application.
First, you need to create an Account on HeyWatch. You have a sandbox environment to test everything before going for a paid account.
For more information, you can read the full API documentation, the Dev Center
require File.join(File.dirname(__FILE__), "HeyWatchVideoEncoding.rb")
# Install the Mashape gem: gem install mashape
# Basic instantiation. TODO Put your authentication keys here.
client = HeyWatchVideoEncoding.new("MASHAPE_KEY", "API_USERNAME", "API_PASSWORD")
# get all your videos
res = client.getAllVideos
p res.body
[
{
"created_at": "2011-06-15T12:05:25+02:00",
"title": "d41d8cd98f00b204e9800998ecf8427e",
"specs": {
"audio": {
"sample_rate": 24000,
"synched": true,
"stream": 0.1,
"codec": "aac",
"bitrate": 0,
"channels": 2
},
"size": 318,
"thumb": "http://raw-2.heywatch.com/5978aa591569a2e5e47805c8c008b1a2/CGI.29806.0.jpg",
"mime_type": "video/mp4",
"video": {
"stream": 0.0,
"codec": "mpeg4",
"container": "mov",
"aspect": 1.33,
"bitrate": 501,
"height": 240,
"length": 5,
"fps": 0.0,
"width": 320
}
},
"updated_at": "2011-06-15T12:05:25+02:00",
"id": 9662090
}
]
# get information about a specific video
res = client.getVideo(9662090)
p res.body
res = client.transferVideo("http://site.com/yourvideo.mp4", "yourtitle")
p res.body
{
"created_at": "2011-06-15T19:00:11+02:00",
"error_msg": null,
"title": "yourtitle",
"video_id": 0,
"updated_at": "2011-06-15T19:00:11+02:00",
"url": "http://site.com/yourvideo.mp4",
"progress": {
"current_length": 0,
"speed": 0,
"percent": 0,
"time_left": "??"
},
"id": 4950011,
"error_code": null,
"length": 0,
"status": "pending"
}
res = client.createJob(9662090, 31, "http://yoursite.com/ping/heywatch?postid=123434", nil, s3directive="s3://accesskey:secretkey@myvideobucket/flv/123434.flv")
{
"ping_url": "http://yoursite.com/ping/heywatch?postid=123434",
"cf_directive": null,
"error_msg": null,
"created_at": "2011-06-15T12:13:13+02:00",
"video_id": 9662090,
"updated_at": "2011-06-15T12:13:13+02:00",
"progress": 0,
"s3_directive": "s3://accesskey:secretkey@myvideobucket/flv/123434.flv",
"format_id": 31,
"id": 4944088,
"error_code": null,
"ftp_directive": null,
"encoded_video_id": 0,
"encoding_options": {
"keep_video_size": true
},
"status": "pending",
"http_upload_directive": null
}
# Will return the binary data directly
res = client.generateEncodedVideoThumbnailSync(9662142, 2, 320, 180)
File.open("thumb.jpg", "w") {|f| f.write(res.raw_body) }
You need to install the heywatch ruby gem:
sudo gem install heywatch
Usage: heywatch RESOURCE:METHOD [ID] [parameter1=value1 parameter2=value2 ...]
Resources:
account # manage account | create, update
video # manage video | all, info, delete, count, bin
encoded_video # manage encoded video | all, info, delete, count, bin, jpg
download # manage download | all, info, delete, count, create
job # manage job | all, info, delete, count, create
format # manage format | all, info, delete, count, create, update
upload # upload a video
Usage:
heywatch account
heywatch account:update env=sandbox
heywatch video:info 123456
heywatch job:all
heywatch download:create url=http://site.com/video.mp4 title=mytitle
heywatch encoded_video:jpg 9882322 start=4 > thumb.jpg
heywatch format:all owner=true video_codec=h264
heywatch video:all "[0]"
heywatch job:all "[0..10]"
heywatch format:count owner=true
heywatch upload path/to/video.mp4 "title=my title"
Released under the MIT license.