uencode 0.0.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +57 -31
- data/lib/uencode/elements.rb +159 -115
- data/lib/uencode/request.rb +21 -11
- data/lib/uencode/response.rb +20 -14
- data/lib/uencode/version.rb +3 -1
- data/lib/uencode.rb +2 -0
- data/uencode.gemspec +4 -12
- metadata +72 -156
- data/spec/elements_spec.rb +0 -532
- data/spec/fixtures/configuration.yaml +0 -23
- data/spec/fixtures/job_with_one_video_and_no_capture.yml +0 -87
- data/spec/request_spec.rb +0 -53
- data/spec/response_spec.rb +0 -48
- data/spec/spec_helper.rb +0 -16
- data/spec/uencode_spec.rb +0 -14
data/spec/elements_spec.rb
DELETED
@@ -1,532 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe UEncode::Medium do
|
4
|
-
let(:medium) { UEncode::Medium.new }
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
medium.configure_video do |c|
|
8
|
-
c.bitrate = 10000
|
9
|
-
c.codec = "mp4"
|
10
|
-
c.cbr = false
|
11
|
-
c.crop = nil
|
12
|
-
c.deinterlace = true
|
13
|
-
c.framerate = UEncode::FrameRate.new :numerator => 1000, :denominator => 1001
|
14
|
-
c.height = 500
|
15
|
-
c.keyframe_interval = 0
|
16
|
-
c.maxbitrate = 10000
|
17
|
-
c.par = nil
|
18
|
-
c.profile = "baseline"
|
19
|
-
c.passes = 1
|
20
|
-
c.stretch = false
|
21
|
-
c.width = 400
|
22
|
-
end
|
23
|
-
|
24
|
-
medium.configure_audio do |c|
|
25
|
-
c.codec = "aac"
|
26
|
-
c.bitrate = 15000
|
27
|
-
c.channels = 2
|
28
|
-
c.samplerate = 10000
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#configure_video" do
|
33
|
-
let(:medium) { UEncode::Medium.new }
|
34
|
-
let(:config) { YAML::load_file("spec/fixtures/configuration.yaml") }
|
35
|
-
let(:video_config) { config["video"] }
|
36
|
-
let(:audio_config) { config["audio"] }
|
37
|
-
|
38
|
-
it { medium.video.bitrate.should == 10000 }
|
39
|
-
it { medium.video.codec.should == "mp4" }
|
40
|
-
it { medium.video.cbr.should == false }
|
41
|
-
it { medium.video.crop.should be_nil }
|
42
|
-
it { medium.video.deinterlace.should == true }
|
43
|
-
it { medium.video.framerate.numerator.should == 1000 }
|
44
|
-
it { medium.video.height.should == 500 }
|
45
|
-
it { medium.video.keyframe_interval.should == 0 }
|
46
|
-
it { medium.video.maxbitrate.should == 10000 }
|
47
|
-
it { medium.video.par.should be_nil }
|
48
|
-
it { medium.video.profile.should == "baseline" }
|
49
|
-
it { medium.video.passes.should == 1 }
|
50
|
-
it { medium.video.stretch.should == false }
|
51
|
-
it { medium.video.width.should == 400 }
|
52
|
-
|
53
|
-
context "from a hash (video parameters)" do
|
54
|
-
subject { medium.video_config }
|
55
|
-
|
56
|
-
before { medium.configure config }
|
57
|
-
|
58
|
-
its(:bitrate) { should == video_config["bitrate"] }
|
59
|
-
its(:codec) { should == video_config["codec"] }
|
60
|
-
its(:cbr) { should == video_config["cbr"] }
|
61
|
-
its(:crop) { should == video_config["crop"] }
|
62
|
-
its(:deinterlace) { should == video_config["deinterlace"] }
|
63
|
-
its(:framerate) { should == UEncode::FrameRate.new(video_config["framerate"]) }
|
64
|
-
its(:height) { should == video_config["height"] }
|
65
|
-
its(:keyframe_interval) { should == video_config["keyframe_interval"] }
|
66
|
-
its(:maxbitrate) { should == video_config["maxbitrate"] }
|
67
|
-
its(:par) { should == UEncode::Par.new(video_config["par"]) }
|
68
|
-
its(:profile) { should == video_config["profile"] }
|
69
|
-
its(:passes) { should == video_config["passes"] }
|
70
|
-
its(:stretch) { should == video_config["stretch"] }
|
71
|
-
its(:width) { should == video_config["width"] }
|
72
|
-
end
|
73
|
-
|
74
|
-
context "from a hash (audio parameters)" do
|
75
|
-
before { medium.configure config }
|
76
|
-
subject { medium.audio_config }
|
77
|
-
|
78
|
-
its(:codec) { should == audio_config["codec"] }
|
79
|
-
its(:bitrate) { should == audio_config["bitrate"] }
|
80
|
-
its(:channels) { should == audio_config["channels"] }
|
81
|
-
its(:samplerate) { should == audio_config["samplerate"] }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "#configure_audio" do
|
86
|
-
let(:medium) { UEncode::Medium.new }
|
87
|
-
|
88
|
-
it { medium.audio.codec.should == "aac" }
|
89
|
-
it { medium.audio.bitrate.should == 15000 }
|
90
|
-
it { medium.audio.channels.should == 2 }
|
91
|
-
it { medium.audio.samplerate.should == 10000 }
|
92
|
-
end
|
93
|
-
|
94
|
-
context "video config default values" do
|
95
|
-
let(:medium_without_configuration) { described_class.new }
|
96
|
-
|
97
|
-
it { medium_without_configuration.video.cbr.should == false }
|
98
|
-
it { medium_without_configuration.video.deinterlace.should == false }
|
99
|
-
it { medium_without_configuration.video.profile.should == "main" }
|
100
|
-
it { medium_without_configuration.video.passes.should == 1 }
|
101
|
-
it { medium_without_configuration.video.stretch.should == false }
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "#to_xml" do
|
105
|
-
let(:xml) { Nokogiri::XML medium.to_xml }
|
106
|
-
|
107
|
-
before :each do
|
108
|
-
medium.configure_video do |c|
|
109
|
-
c.crop = UEncode::Crop.new :width => 125, :height => 150, :x => 100, :y => 200
|
110
|
-
c.par = UEncode::Par.new :numerator => 10, :denominator => 11
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
it "has a root element named 'media'" do
|
115
|
-
xml.root.name.should == 'medium'
|
116
|
-
end
|
117
|
-
|
118
|
-
it "has the correct video configs" do
|
119
|
-
config = xml.xpath("//video")
|
120
|
-
config.xpath("//video/bitrate").text.should == "10000"
|
121
|
-
config.xpath("//video/codec").text.should == "mp4"
|
122
|
-
config.xpath("//cbr").text.should == "false"
|
123
|
-
config.xpath("//crop/width").text.should == "125"
|
124
|
-
config.xpath("//crop/height").text.should == "150"
|
125
|
-
config.xpath("//crop/x").text.should == "100"
|
126
|
-
config.xpath("//crop/y").text.should == "200"
|
127
|
-
config.xpath("//deinterlace").text.should == "true"
|
128
|
-
config.xpath("//framerate/numerator").text.should == "1000"
|
129
|
-
config.xpath("//framerate/denominator").text.should == "1001"
|
130
|
-
config.xpath("//video/height").text.should == "500"
|
131
|
-
config.xpath("//keyframe_interval").text.should == "0"
|
132
|
-
config.xpath("//maxbitrate").text.should == "10000"
|
133
|
-
config.xpath("//par/numerator").text.should == "10"
|
134
|
-
config.xpath("//par/denominator").text.should == "11"
|
135
|
-
config.xpath("//profile").text.should == "baseline"
|
136
|
-
config.xpath("//passes").text.should == "1"
|
137
|
-
config.xpath("//video/width").text.should == "400"
|
138
|
-
end
|
139
|
-
|
140
|
-
it "does not include the cbr video config when it's null" do
|
141
|
-
medium.configure_video { |c| c.cbr = nil }
|
142
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/cbr").should be_empty
|
143
|
-
end
|
144
|
-
|
145
|
-
it "does not include the crop video config when it's null" do
|
146
|
-
medium.configure_video { |c| c.crop = nil }
|
147
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/crop").should be_empty
|
148
|
-
end
|
149
|
-
|
150
|
-
it "does not include the deinterlace video config when it's null" do
|
151
|
-
medium.configure_video { |c| c.deinterlace = nil }
|
152
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/deinterlace").should be_empty
|
153
|
-
end
|
154
|
-
|
155
|
-
it "does not include the framerate video config when it's null" do
|
156
|
-
medium.configure_video { |c| c.framerate = nil }
|
157
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/framerate").should be_empty
|
158
|
-
end
|
159
|
-
|
160
|
-
it "does not include the height video config when it's null" do
|
161
|
-
medium.configure_video { |c| c.height = nil }
|
162
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/height").should be_empty
|
163
|
-
end
|
164
|
-
|
165
|
-
it "does not include the keyframe_interval video config when it's null" do
|
166
|
-
medium.configure_video { |c| c.keyframe_interval = nil }
|
167
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/keyframe_interval").should be_empty
|
168
|
-
end
|
169
|
-
|
170
|
-
it "does not include the maxbitrate video config when it's null" do
|
171
|
-
medium.configure_video { |c| c.maxbitrate = nil }
|
172
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/maxbitrate").should be_empty
|
173
|
-
end
|
174
|
-
|
175
|
-
it "does not include the par video config when it's null" do
|
176
|
-
medium.configure_video { |c| c.par = nil }
|
177
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/par").should be_empty
|
178
|
-
end
|
179
|
-
|
180
|
-
it "does not include the profile video config when it's null" do
|
181
|
-
medium.configure_video { |c| c.profile = nil }
|
182
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/profile").should be_empty
|
183
|
-
end
|
184
|
-
|
185
|
-
it "does not include the passes video config when it's null" do
|
186
|
-
medium.configure_video { |c| c.passes = nil }
|
187
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/passes").should be_empty
|
188
|
-
end
|
189
|
-
|
190
|
-
it "does not include the stretch video config when it's null" do
|
191
|
-
medium.configure_video { |c| c.stretch = nil }
|
192
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/stretch").should be_empty
|
193
|
-
end
|
194
|
-
|
195
|
-
it "does not include the width video config when it's null" do
|
196
|
-
medium.configure_video { |c| c.width = nil }
|
197
|
-
Nokogiri::XML(medium.to_xml).xpath("//video/width").should be_empty
|
198
|
-
end
|
199
|
-
|
200
|
-
it "does not include the stretch video config when it's false" do
|
201
|
-
medium.configure_video { |c| c.stretch = false }
|
202
|
-
Nokogiri::XML(medium.to_xml) .xpath("//video/stretch").should be_empty
|
203
|
-
end
|
204
|
-
|
205
|
-
it "has the correct audio configs" do
|
206
|
-
xml.xpath("//audio/codec").text.should == "aac"
|
207
|
-
xml.xpath("//audio/bitrate").text.should == "15000"
|
208
|
-
xml.xpath("//audio/channels").text.should == "2"
|
209
|
-
xml.xpath("//audio/samplerate").text.should == "10000"
|
210
|
-
end
|
211
|
-
|
212
|
-
it "does not include the bitrate audio config when it's null" do
|
213
|
-
medium.configure_audio { |c| c.bitrate = nil }
|
214
|
-
Nokogiri::XML(medium.to_xml).xpath("//audio/bitrate").should be_empty
|
215
|
-
end
|
216
|
-
|
217
|
-
it "does not include the channels audio config when it's null" do
|
218
|
-
medium.configure_audio { |c| c.channels = nil }
|
219
|
-
Nokogiri::XML(medium.to_xml).xpath("//audio/channels").should be_empty
|
220
|
-
end
|
221
|
-
|
222
|
-
it "does not include the samplerate audio config when it's null" do
|
223
|
-
medium.configure_audio { |c| c.samplerate = nil }
|
224
|
-
Nokogiri::XML(medium.to_xml).xpath("//audio/samplerate").should be_empty
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
describe UEncode::VideoOutput do
|
230
|
-
subject { described_class.new :destination => "http://foobar.com/bla.avi", :container => "mpeg4" }
|
231
|
-
|
232
|
-
its(:destination) { should == "http://foobar.com/bla.avi" }
|
233
|
-
its(:container) { should == "mpeg4" }
|
234
|
-
|
235
|
-
|
236
|
-
describe "#to_xml" do
|
237
|
-
let(:video_output) { described_class.new :destination => "http://foo.com/bar.mp4", :container => "mpeg4" }
|
238
|
-
let(:xml) { Nokogiri::XML video_output.to_xml }
|
239
|
-
|
240
|
-
|
241
|
-
it "has a root element named 'output'" do
|
242
|
-
xml.root.name.should == 'output'
|
243
|
-
end
|
244
|
-
|
245
|
-
it "has the correct destination value" do
|
246
|
-
xml.xpath("//output/video/destination").text.should == "http://foo.com/bar.mp4"
|
247
|
-
end
|
248
|
-
|
249
|
-
it "has the correct container value" do
|
250
|
-
xml.xpath("//output/video/container").text.should == "mpeg4"
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe UEncode::CaptureOutput do
|
256
|
-
subject { described_class.new({
|
257
|
-
:destination => "http://whatever.com/foo.jpg",
|
258
|
-
:rate => "at 20s",
|
259
|
-
:stretch => false
|
260
|
-
}) }
|
261
|
-
|
262
|
-
its(:destination) { should == "http://whatever.com/foo.jpg" }
|
263
|
-
its(:rate) { should == "at 20s" }
|
264
|
-
its(:stretch) { should == false }
|
265
|
-
|
266
|
-
context "default values" do
|
267
|
-
let(:capture) { described_class.new :rate => "every 10s" }
|
268
|
-
|
269
|
-
it { capture.stretch.should == false }
|
270
|
-
end
|
271
|
-
|
272
|
-
describe "#to_xml" do
|
273
|
-
let(:crop) { UEncode::Crop.new :width => 125, :height => 140, :x => 100, :y => 200 }
|
274
|
-
let(:size) { UEncode::Size.new :width => 400, :height => 500 }
|
275
|
-
let(:xml) {
|
276
|
-
Nokogiri::XML described_class.new(
|
277
|
-
:destination => "http://foo.com/bla.mp4",
|
278
|
-
:stretch => false,
|
279
|
-
:rate => 'every 10s',
|
280
|
-
:crop => crop,
|
281
|
-
:size => size
|
282
|
-
).to_xml
|
283
|
-
}
|
284
|
-
|
285
|
-
it "has a root element named capture" do
|
286
|
-
xml.root.name.should == 'output'
|
287
|
-
end
|
288
|
-
|
289
|
-
it "has the correct value for the rate attribute" do
|
290
|
-
xml.xpath("//output/capture/rate").text.should == "every 10s"
|
291
|
-
end
|
292
|
-
|
293
|
-
it "has the correct value for the destination attribute" do
|
294
|
-
xml.xpath("//output/capture/destination").text.should == "http://foo.com/bla.mp4"
|
295
|
-
end
|
296
|
-
|
297
|
-
it "has the correct value for the crop attribute" do
|
298
|
-
xml.xpath("//output/capture/crop/width").text.should == "125"
|
299
|
-
xml.xpath("//output/capture/crop/height").text.should == "140"
|
300
|
-
end
|
301
|
-
|
302
|
-
it "has the correct value for the size attribute" do
|
303
|
-
xml.xpath("//output/capture/size/width").text.should == "400"
|
304
|
-
xml.xpath("//output/capture/size/height").text.should == "500"
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
describe UEncode::Crop do
|
310
|
-
subject { described_class.new :width => 100, :height => 200, :x => 100, :y => 150 }
|
311
|
-
|
312
|
-
its(:width) { should == 100 }
|
313
|
-
its(:height) { should == 200 }
|
314
|
-
its(:x) { should == 100 }
|
315
|
-
its(:y) { should = 150 }
|
316
|
-
|
317
|
-
describe "#to_xml" do
|
318
|
-
let(:xml) { Nokogiri::XML described_class.new(:width => 100, :height => 200, :x => 100, :y => 150).to_xml }
|
319
|
-
|
320
|
-
it "has a root element named 'crop'" do
|
321
|
-
xml.root.name.should == 'crop'
|
322
|
-
end
|
323
|
-
|
324
|
-
it "has the correct value for the width attribute" do
|
325
|
-
xml.xpath("//width").text.should == "100"
|
326
|
-
end
|
327
|
-
|
328
|
-
it "has the correct value for the height attribute" do
|
329
|
-
xml.xpath("//height").text.should == "200"
|
330
|
-
end
|
331
|
-
|
332
|
-
it "has the correct value for the x attribute" do
|
333
|
-
xml.xpath("//x").text.should == "100"
|
334
|
-
end
|
335
|
-
|
336
|
-
it "has the correct value for the y attribute" do
|
337
|
-
xml.xpath("//y").text.should == "150"
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
shared_examples_for "an element that represents a rate number" do
|
343
|
-
subject { described_class.new :numerator => numerator, :denominator => denominator }
|
344
|
-
|
345
|
-
its(:numerator) { should == numerator }
|
346
|
-
its(:denominator) { should == denominator }
|
347
|
-
|
348
|
-
describe "#to_xml" do
|
349
|
-
let(:xml) { Nokogiri::XML described_class.new(:numerator => numerator, :denominator => denominator).to_xml }
|
350
|
-
|
351
|
-
it "has a root element named '#{name}'" do
|
352
|
-
xml.root.name.should == name
|
353
|
-
end
|
354
|
-
|
355
|
-
it "has the correct value for the numerator attribute" do
|
356
|
-
xml.xpath("//numerator").text.should == numerator.to_s
|
357
|
-
end
|
358
|
-
|
359
|
-
it "has the correct value for the denominator attribute" do
|
360
|
-
xml.xpath("//denominator").text.should == denominator.to_s
|
361
|
-
end
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
describe UEncode::VideoConfig do
|
366
|
-
let(:config) { described_class.new }
|
367
|
-
|
368
|
-
context "receiving a hash as the framerate" do
|
369
|
-
before { config.framerate = {:numerator => 123, :denominator => 345} }
|
370
|
-
|
371
|
-
it "converts it to a UEncode::FrameRate" do
|
372
|
-
config.framerate.should be_an_instance_of(UEncode::FrameRate)
|
373
|
-
end
|
374
|
-
|
375
|
-
it "the framerate has the correct numerator" do
|
376
|
-
config.framerate.numerator.should == 123
|
377
|
-
end
|
378
|
-
|
379
|
-
it "the framerate has the correct denominator" do
|
380
|
-
config.framerate.denominator.should == 345
|
381
|
-
end
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
describe UEncode::FrameRate do
|
386
|
-
let(:name) { "framerate" }
|
387
|
-
let(:numerator) { 1000 }
|
388
|
-
let(:denominator) { 1001 }
|
389
|
-
|
390
|
-
it_should_behave_like "an element that represents a rate number"
|
391
|
-
end
|
392
|
-
|
393
|
-
describe UEncode::Par do
|
394
|
-
let(:name) { "par" }
|
395
|
-
let(:numerator) { 10 }
|
396
|
-
let(:denominator) { 11 }
|
397
|
-
|
398
|
-
it_should_behave_like "an element that represents a rate number"
|
399
|
-
end
|
400
|
-
|
401
|
-
describe UEncode::Size do
|
402
|
-
subject { described_class.new :width => 100, :height => 200 }
|
403
|
-
|
404
|
-
its(:height) { should == 200 }
|
405
|
-
its(:width) { should == 100 }
|
406
|
-
|
407
|
-
describe "#to_xml" do
|
408
|
-
let(:xml) { Nokogiri::XML described_class.new(:width => 200, :height => 250).to_xml }
|
409
|
-
|
410
|
-
it "has a root element named 'size'" do
|
411
|
-
xml.root.name.should == 'size'
|
412
|
-
end
|
413
|
-
|
414
|
-
it "has the correct value for the width attribute" do
|
415
|
-
xml.xpath("//width").text.should == "200"
|
416
|
-
end
|
417
|
-
|
418
|
-
it "has the correct value for the height attribute" do
|
419
|
-
xml.xpath("//height").text.should == "250"
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
describe UEncode::Job do
|
425
|
-
subject { described_class.new :source => "http://foo.com/bar.avi", :userdata => "some text", :notify => "http://my_url.com" }
|
426
|
-
|
427
|
-
its(:source) { should == "http://foo.com/bar.avi" }
|
428
|
-
its(:userdata) { should == "some text" }
|
429
|
-
its(:notify) { should == "http://my_url.com" }
|
430
|
-
its(:items) { should == [] }
|
431
|
-
|
432
|
-
describe "#<<" do
|
433
|
-
it "adds new elements to items" do
|
434
|
-
subject << "foo"
|
435
|
-
subject.items.should == ["foo"]
|
436
|
-
end
|
437
|
-
end
|
438
|
-
|
439
|
-
it "is enumerable" do
|
440
|
-
subject << "foo"
|
441
|
-
subject << "bar"
|
442
|
-
subject.map { |item| item }.should == ["foo", "bar"]
|
443
|
-
end
|
444
|
-
|
445
|
-
describe "#to_xml" do
|
446
|
-
let(:job) { UEncode::Job.new({
|
447
|
-
:customerkey => "0123456789",
|
448
|
-
:source => "http://whatever.com/foo.avi",
|
449
|
-
:userdata => "some text",
|
450
|
-
:notify => "http://notify.me/meh"
|
451
|
-
})}
|
452
|
-
|
453
|
-
let(:xml) { Nokogiri::XML job.to_xml }
|
454
|
-
|
455
|
-
before :each do
|
456
|
-
video1 = UEncode::Medium.new
|
457
|
-
video1.configure_video do |c|
|
458
|
-
c.bitrate = 1000
|
459
|
-
c.codec = 'mp4'
|
460
|
-
end
|
461
|
-
video1.configure_audio do |c|
|
462
|
-
c.codec = 'aac'
|
463
|
-
end
|
464
|
-
video2 = UEncode::Medium.new
|
465
|
-
video2.configure_video do |c|
|
466
|
-
c.bitrate = 1500
|
467
|
-
c.codec = 'mpeg2'
|
468
|
-
end
|
469
|
-
video2.configure_audio do |c|
|
470
|
-
c.codec = 'passthru'
|
471
|
-
end
|
472
|
-
job << video1
|
473
|
-
job << video2
|
474
|
-
|
475
|
-
job.configure_video_output do |c|
|
476
|
-
c.destination = "http://whatever.com/foo1.mp4"
|
477
|
-
c.container = "mpeg4"
|
478
|
-
end
|
479
|
-
|
480
|
-
capture1 = UEncode::CaptureOutput.new :destination => "http://whatever.com/foo.zip", :rate => "every 30s"
|
481
|
-
job.add_capture capture1
|
482
|
-
capture2 = UEncode::CaptureOutput.new :destination => "http://whatever.com/bar.zip", :rate => "every 10s"
|
483
|
-
job.add_capture capture2
|
484
|
-
end
|
485
|
-
|
486
|
-
it "has a root element named 'job'" do
|
487
|
-
xml.root.name.should == 'job'
|
488
|
-
end
|
489
|
-
|
490
|
-
it "has the correct customer key value" do
|
491
|
-
xml.xpath("//job/customerkey").text.should == "1q2w3e4r5t"
|
492
|
-
end
|
493
|
-
|
494
|
-
it "has the correct source attribute" do
|
495
|
-
xml.xpath("//job/source").text.should == "http://whatever.com/foo.avi"
|
496
|
-
end
|
497
|
-
|
498
|
-
it "has the correct user data value" do
|
499
|
-
xml.xpath("//job/userdata").text.should == 'some text'
|
500
|
-
end
|
501
|
-
|
502
|
-
it "has the correct notify value" do
|
503
|
-
xml.xpath("//job/notify").text.should == "http://notify.me/meh"
|
504
|
-
end
|
505
|
-
|
506
|
-
it "does not include the userdata attribute when it's null" do
|
507
|
-
job.instance_variable_set :@userdata, nil
|
508
|
-
xml.xpath("//job/userdata").should be_empty
|
509
|
-
end
|
510
|
-
|
511
|
-
it "does not include the notify attribute when it's null" do
|
512
|
-
job.instance_variable_set :@notify, nil
|
513
|
-
xml.xpath("//job/notify").should be_empty
|
514
|
-
end
|
515
|
-
|
516
|
-
it "contains the correct content to represent each video output item" do
|
517
|
-
xml.xpath("//job/outputs/output/video/media/medium").length.should == 2
|
518
|
-
end
|
519
|
-
|
520
|
-
it "has the correct video output destination" do
|
521
|
-
xml.xpath("//job/outputs/output/video/destination").text.should == "http://whatever.com/foo1.mp4"
|
522
|
-
end
|
523
|
-
|
524
|
-
it "has the correct video output container" do
|
525
|
-
xml.xpath("//job/outputs/output/video/container").text.should == "mpeg4"
|
526
|
-
end
|
527
|
-
|
528
|
-
it "contains the correct content to represent the video captures" do
|
529
|
-
xml.xpath("//job/outputs/output/capture").length.should == 2
|
530
|
-
end
|
531
|
-
end
|
532
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
video:
|
2
|
-
bitrate: 4500000
|
3
|
-
codec: "mp4"
|
4
|
-
width: 1920
|
5
|
-
height: 1080
|
6
|
-
passes: 1
|
7
|
-
maxbitrate: 2000000
|
8
|
-
deinterlace: false
|
9
|
-
cbr: false
|
10
|
-
stretch: false
|
11
|
-
profile: "baseline"
|
12
|
-
framerate:
|
13
|
-
numerator: 30000
|
14
|
-
denominator: 1001
|
15
|
-
par:
|
16
|
-
numerator: 1
|
17
|
-
denominator: 1
|
18
|
-
keyframe_interval: 60
|
19
|
-
audio:
|
20
|
-
codec: "aac"
|
21
|
-
bitrate: 256000
|
22
|
-
channels: 2
|
23
|
-
samplerate: 44100
|
@@ -1,87 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- !ruby/struct:VCR::HTTPInteraction
|
3
|
-
request: !ruby/struct:VCR::Request
|
4
|
-
method: :put
|
5
|
-
uri: https://www.uencode.com:443/jobs?version=300
|
6
|
-
body: |
|
7
|
-
<?xml version="1.0"?>
|
8
|
-
<job>
|
9
|
-
<customerkey>1q2w3e4r5t</customerkey>
|
10
|
-
<source>http://dailydigital-files.s3.amazonaws.com/staging/3/iphone.mp4</source>
|
11
|
-
<userdata>This is a simple test</userdata>
|
12
|
-
|
13
|
-
<outputs>
|
14
|
-
|
15
|
-
<output>
|
16
|
-
<video>
|
17
|
-
<destination>http://dailydigital-files.s3.amazonaws.com/staging/3/iphone_transcoded.mp4</destination>
|
18
|
-
<container>mpeg4</container>
|
19
|
-
<media>
|
20
|
-
|
21
|
-
<medium>
|
22
|
-
<video>
|
23
|
-
<bitrate>300000</bitrate>
|
24
|
-
<codec>h264</codec>
|
25
|
-
<cbr>false</cbr>
|
26
|
-
|
27
|
-
<deinterlace>false</deinterlace>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<profile>main</profile>
|
34
|
-
<passes>1</passes>
|
35
|
-
|
36
|
-
|
37
|
-
</video>
|
38
|
-
<audio>
|
39
|
-
<codec>aac</codec>
|
40
|
-
<bitrate>64000</bitrate>
|
41
|
-
<channels>1</channels>
|
42
|
-
<samplerate>44100</samplerate>
|
43
|
-
</audio>
|
44
|
-
</medium>
|
45
|
-
|
46
|
-
</media>
|
47
|
-
</video>
|
48
|
-
</output>
|
49
|
-
|
50
|
-
|
51
|
-
</outputs>
|
52
|
-
</job>
|
53
|
-
|
54
|
-
headers:
|
55
|
-
response: !ruby/struct:VCR::Response
|
56
|
-
status: !ruby/struct:VCR::ResponseStatus
|
57
|
-
code: 200
|
58
|
-
message: OK
|
59
|
-
headers:
|
60
|
-
date:
|
61
|
-
- Wed, 18 May 2011 21:25:41 GMT
|
62
|
-
server:
|
63
|
-
- Apache/2.2.16 (Ubuntu)
|
64
|
-
etag:
|
65
|
-
- "\"1c1e90e26e3f60eeb74014a6aeb5ac22\""
|
66
|
-
cache-control:
|
67
|
-
- max-age=0, private, must-revalidate
|
68
|
-
x-ua-compatible:
|
69
|
-
- IE=Edge,chrome=1
|
70
|
-
set-cookie:
|
71
|
-
- _uencode_api_session=BAh7BiIPc2Vzc2lvbl9pZCIlOWM4ZWM4ZGUxMzNiNTNiNWZiOWMwMDA4ODkzMmY3ZWI%3D--697ce08be3ca2a9f6347474fe7fe5476333e9408; path=/; HttpOnly
|
72
|
-
x-runtime:
|
73
|
-
- "1.007000"
|
74
|
-
content-length:
|
75
|
-
- "202"
|
76
|
-
content-type:
|
77
|
-
- application/xml;charset=utf-8
|
78
|
-
body: |
|
79
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
80
|
-
<response>
|
81
|
-
<code>Ok</code>
|
82
|
-
<jobid>6068</jobid>
|
83
|
-
<message>You job was created successfully.</message>
|
84
|
-
<userdata>This is a simple test</userdata>
|
85
|
-
</response>
|
86
|
-
|
87
|
-
http_version: "1.1"
|
data/spec/request_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe UEncode::Request do
|
4
|
-
context "being created" do
|
5
|
-
let(:job) { UEncode::Job.new :source => "http://whatever.com/foo/avi" }
|
6
|
-
let(:request) { UEncode::Request.new job }
|
7
|
-
|
8
|
-
it "initializes the job attribute" do
|
9
|
-
request.instance_variable_get(:@job).should == job
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#send" do
|
14
|
-
let(:job) { UEncode::Job.new :source => "http://dailydigital-files.s3.amazonaws.com/staging/3/iphone.mp4", :userdata => "This is a simple test" }
|
15
|
-
let(:request) { UEncode::Request.new job }
|
16
|
-
|
17
|
-
before :each do
|
18
|
-
job.configure_video_output do |c|
|
19
|
-
c.destination = "http://dailydigital-files.s3.amazonaws.com/staging/3/iphone_transcoded.mp4"
|
20
|
-
c.container = "mpeg4"
|
21
|
-
end
|
22
|
-
video1 = UEncode::Medium.new
|
23
|
-
video1.configure_video { |c| c.bitrate = 300000; c.codec = "h264"}
|
24
|
-
video1.configure_audio do |c|
|
25
|
-
c.bitrate = 64000
|
26
|
-
c.codec = "aac"
|
27
|
-
c.samplerate = 44100
|
28
|
-
c.channels = 1
|
29
|
-
end
|
30
|
-
job << video1
|
31
|
-
end
|
32
|
-
|
33
|
-
around :each do |example|
|
34
|
-
VCR.use_cassette "job_with_one_video_and_no_capture", &example
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns a response containing the jobid" do
|
38
|
-
request.send.jobid.should =~ /\A\d+\z/
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns a response containing a code" do
|
42
|
-
request.send.code.should == 'Ok'
|
43
|
-
end
|
44
|
-
|
45
|
-
it "returns a response containing the previously sent user data" do
|
46
|
-
request.send.userdata.should == "This is a simple test"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns a response containing a message" do
|
50
|
-
request.send.message.should == "You job was created successfully."
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|