zencoder 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +23 -0
- data/History.txt +8 -0
- data/Manifest.txt +8 -0
- data/README.txt +101 -0
- data/Rakefile +16 -0
- data/bin/zencoder +3 -0
- data/lib/zencoder.rb +31 -0
- data/test/test_zencoder.rb +65 -0
- metadata +131 -0
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
= Zencoder
|
2
|
+
|
3
|
+
* http://www.bitbucket.org/mml/zencoder
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
A small library for interacting with Zencoder.com services.
|
8
|
+
|
9
|
+
See http://www.Zencoder.com for more details.
|
10
|
+
|
11
|
+
== FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
* None yet
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
Zencoder.submit_job('somebigapikeynumberthing','s3://bucket/path/to/file.mov', ZencoderAPI::Recipes.iphone({:override=>value}))
|
18
|
+
|
19
|
+
== REQUIREMENTS:
|
20
|
+
|
21
|
+
* rest-client
|
22
|
+
|
23
|
+
== INSTALL:
|
24
|
+
|
25
|
+
* Get your api key from Zencoder.com, and install the gem.
|
26
|
+
|
27
|
+
== DEVELOPERS:
|
28
|
+
|
29
|
+
Here's the biggest input i could generate using the awesome Zencoder api builder. Note that it's nonsensical, as
|
30
|
+
it turns on both skip audio and skip video flags.
|
31
|
+
{
|
32
|
+
"test": 1,
|
33
|
+
"input": "s3://mybucket/foo",
|
34
|
+
"output": [
|
35
|
+
{
|
36
|
+
"label": "iphone",
|
37
|
+
"base_url": "s3://mybucket/",
|
38
|
+
"filename": "packet/7/movie.flv",
|
39
|
+
"width": 600,
|
40
|
+
"height": 300,
|
41
|
+
"quality": 3,
|
42
|
+
"speed": 3,
|
43
|
+
"upscale": 1,
|
44
|
+
"stretch": 1,
|
45
|
+
"frame_rate": 29.997,
|
46
|
+
"max_frame_rate": 30,
|
47
|
+
"keyframe_interval": 30,
|
48
|
+
"video_bitrate": 500,
|
49
|
+
"bitrate_cap": 600,
|
50
|
+
"buffer_size": 500,
|
51
|
+
"h264_profile": "high",
|
52
|
+
"h264_level": 2.2,
|
53
|
+
"skip_video": 1,
|
54
|
+
"audio_codec": "aac",
|
55
|
+
"audio_bitrate": 200,
|
56
|
+
"audio_channels": 2,
|
57
|
+
"audio_sample_rate": 128,
|
58
|
+
"skip_audio": 1,
|
59
|
+
"thumbnails": {
|
60
|
+
"number": 30,
|
61
|
+
"size": "100x100",
|
62
|
+
"base_url": "s3://thumbnails",
|
63
|
+
"prefix": "fname_prefix"
|
64
|
+
},
|
65
|
+
"notifications": [
|
66
|
+
"http://callback",
|
67
|
+
"m@loonsoft.com"
|
68
|
+
],
|
69
|
+
"start_clip": 20,
|
70
|
+
"clip_length": 30
|
71
|
+
}
|
72
|
+
],
|
73
|
+
"api_key": "your apikey"
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
== LICENSE:
|
79
|
+
|
80
|
+
(The MIT License)
|
81
|
+
|
82
|
+
Copyright (c) 2010 McClain Looney
|
83
|
+
|
84
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
85
|
+
a copy of this software and associated documentation files (the
|
86
|
+
'Software'), to deal in the Software without restriction, including
|
87
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
88
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
89
|
+
permit persons to whom the Software is furnished to do so, subject to
|
90
|
+
the following conditions:
|
91
|
+
|
92
|
+
The above copyright notice and this permission notice shall be
|
93
|
+
included in all copies or substantial portions of the Software.
|
94
|
+
|
95
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
96
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
97
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
98
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
99
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
100
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
101
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'hoe'
|
7
|
+
|
8
|
+
Hoe.plugins.delete :rubyforge
|
9
|
+
|
10
|
+
Hoe.spec 'zencoder' do
|
11
|
+
developer('McClain Looney', 'm@loonsoft.com')
|
12
|
+
extra_deps << %w(rest-client >=1.2.0)
|
13
|
+
extra_dev_deps << %w(shoulda >=2.10.0)
|
14
|
+
end
|
15
|
+
|
16
|
+
# vim: syntax=ruby
|
data/bin/zencoder
ADDED
data/lib/zencoder.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rest_client'
|
3
|
+
require 'json'
|
4
|
+
require 'recipes'
|
5
|
+
# A simple interface for dealing with the zencoder api. Currently just submits jobs. More features to come some day.
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
#
|
9
|
+
# Zencoder.submit_job('somebigapikeynumberthing','s3://bucket/path/to/file.mov', ZencoderAPI::Recipes.iphone({:override=>value}))
|
10
|
+
class Zencoder
|
11
|
+
include ZencoderAPI
|
12
|
+
|
13
|
+
# Currently https://app.zencoder.com/api This means you have to have ssl built into your ruby!
|
14
|
+
API_URL = 'https://app.zencoder.com/api'
|
15
|
+
|
16
|
+
VERSION = '1.0.1' #:nodoc:
|
17
|
+
# Submits a job to zencoder.
|
18
|
+
# The recipe should be an instance or array of instances of ZencoderAPI::Recipe
|
19
|
+
# Exceptions are not handled, but rather propagated upwards.
|
20
|
+
#
|
21
|
+
# If a block is provided, it is yielded the job configuration as a hash.
|
22
|
+
class <<self
|
23
|
+
def submit_job(apikey, src, *recipes)
|
24
|
+
jorb = {:api_key=>apikey, :input => src, :output=>[recipes].flatten}
|
25
|
+
yield jorb if block_given?
|
26
|
+
RestClient.post(API_URL+'/jobs', jorb.to_json, {:content_type=>:json, :accept=>:json})
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "test/unit"
|
3
|
+
require "zencoder"
|
4
|
+
require 'shoulda'
|
5
|
+
require 'mocha'
|
6
|
+
require 'ruby-debug'
|
7
|
+
|
8
|
+
class TestZencoder < Test::Unit::TestCase
|
9
|
+
|
10
|
+
context "the zn lib" do
|
11
|
+
setup do
|
12
|
+
@src='s3://gkt_sophia_development/spark.avi'
|
13
|
+
@api = 'https://app.zencoder.com'
|
14
|
+
@apikey = ENV['ZC_APIKEY']
|
15
|
+
@base_url = 's3://gkt_sophia_development/zencoder_asset'
|
16
|
+
@recipe = ZencoderAPI::Recipes.iphone('base_url' =>@base_url)
|
17
|
+
@recipe2 = ZencoderAPI::Recipes.web('base_url' =>@base_url)
|
18
|
+
assert_not_nil @apikey, "export ZC_APIKEY before you run the tests"
|
19
|
+
end
|
20
|
+
context "posting a new job" do
|
21
|
+
setup do
|
22
|
+
end
|
23
|
+
should "be able to submit a job" do
|
24
|
+
RestClient.expects(:post).with(kind_of(String), kind_of(String), kind_of(Hash)){|x,y,z|
|
25
|
+
assert_equal x, 'https://app.zencoder.com/api/jobs'
|
26
|
+
body = JSON.parse(y)
|
27
|
+
assert_equal body['input'], @src
|
28
|
+
assert_equal body['output'][0]['base_url'], @base_url
|
29
|
+
assert_equal body['output'][1]['base_url'], @base_url
|
30
|
+
assert_equal body['output'][1]['label'], 'web'
|
31
|
+
assert_equal body['output'][0]['label'], 'iphone'
|
32
|
+
assert_equal body['api_key'], @apikey
|
33
|
+
assert_equal z[:content_type], :json
|
34
|
+
assert_equal z[:accept], :json
|
35
|
+
true
|
36
|
+
}
|
37
|
+
Zencoder.submit_job(@apikey, @src, [@recipe, @recipe2])
|
38
|
+
end
|
39
|
+
should "be able to muck the config " do
|
40
|
+
RestClient.expects(:post).with(kind_of(String), kind_of(String), kind_of(Hash)){|x,y,z|
|
41
|
+
body = JSON.parse(y)
|
42
|
+
assert_equal body['foo'],'bar'
|
43
|
+
true
|
44
|
+
}
|
45
|
+
Zencoder.submit_job(@apikey, @src, @recipe) do |config|
|
46
|
+
config[:foo]='bar'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
should "be able to submit a job with 1 recipe" do
|
50
|
+
RestClient.expects(:post).with(kind_of(String), kind_of(String), kind_of(Hash)){|x,y,z|
|
51
|
+
assert_equal x, 'https://app.zencoder.com/api/jobs'
|
52
|
+
body = JSON.parse(y)
|
53
|
+
assert_equal body['input'], @src
|
54
|
+
assert_equal body['output'][0]['base_url'], @base_url
|
55
|
+
assert_equal body['output'][0]['label'], 'iphone'
|
56
|
+
assert_equal body['api_key'], @apikey
|
57
|
+
assert_equal z[:content_type], :json
|
58
|
+
assert_equal z[:accept], :json
|
59
|
+
true
|
60
|
+
}
|
61
|
+
Zencoder.submit_job(@apikey, @src, @recipe)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zencoder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- McClain Looney
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-29 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rest-client
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
version: 1.2.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: gemcutter
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 5
|
44
|
+
- 0
|
45
|
+
version: 0.5.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: shoulda
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 2
|
57
|
+
- 10
|
58
|
+
- 0
|
59
|
+
version: 2.10.0
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: hoe
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 2
|
71
|
+
- 5
|
72
|
+
- 0
|
73
|
+
version: 2.5.0
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
description: |-
|
77
|
+
A small library for interacting with Zencoder.com services.
|
78
|
+
|
79
|
+
See http://www.Zencoder.com for more details.
|
80
|
+
email:
|
81
|
+
- m@loonsoft.com
|
82
|
+
executables:
|
83
|
+
- zencoder
|
84
|
+
extensions: []
|
85
|
+
|
86
|
+
extra_rdoc_files:
|
87
|
+
- History.txt
|
88
|
+
- Manifest.txt
|
89
|
+
- README.txt
|
90
|
+
files:
|
91
|
+
- .autotest
|
92
|
+
- History.txt
|
93
|
+
- Manifest.txt
|
94
|
+
- README.txt
|
95
|
+
- Rakefile
|
96
|
+
- bin/zencoder
|
97
|
+
- lib/zencoder.rb
|
98
|
+
- test/test_zencoder.rb
|
99
|
+
has_rdoc: true
|
100
|
+
homepage: http://www.bitbucket.org/mml/zencoder
|
101
|
+
licenses: []
|
102
|
+
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options:
|
105
|
+
- --main
|
106
|
+
- README.txt
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
requirements: []
|
124
|
+
|
125
|
+
rubyforge_project: zencoder
|
126
|
+
rubygems_version: 1.3.6
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: A small library for interacting with Zencoder.com services
|
130
|
+
test_files:
|
131
|
+
- test/test_zencoder.rb
|