active_encode 0.4.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +80 -0
- data/.rubocop.yml +9 -70
- data/.rubocop_todo.yml +68 -0
- data/CODE_OF_CONDUCT.md +36 -0
- data/CONTRIBUTING.md +23 -21
- data/Gemfile +5 -4
- data/LICENSE +11 -199
- data/README.md +135 -24
- data/SUPPORT.md +5 -0
- data/active_encode.gemspec +13 -3
- data/app/controllers/active_encode/encode_record_controller.rb +13 -0
- data/app/jobs/active_encode/polling_job.rb +1 -1
- data/app/models/active_encode/encode_record.rb +1 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20180822021048_create_active_encode_encode_records.rb +1 -0
- data/db/migrate/20190702153755_add_create_options_to_active_encode_encode_records.rb +6 -0
- data/db/migrate/20190712174821_add_progress_to_active_encode_encode_records.rb +6 -0
- data/lib/active_encode.rb +1 -0
- data/lib/active_encode/base.rb +2 -2
- data/lib/active_encode/callbacks.rb +1 -0
- data/lib/active_encode/core.rb +4 -3
- data/lib/active_encode/engine.rb +1 -0
- data/lib/active_encode/engine_adapter.rb +1 -0
- data/lib/active_encode/engine_adapters.rb +4 -1
- data/lib/active_encode/engine_adapters/elastic_transcoder_adapter.rb +116 -38
- data/lib/active_encode/engine_adapters/ffmpeg_adapter.rb +141 -87
- data/lib/active_encode/engine_adapters/matterhorn_adapter.rb +5 -4
- data/lib/active_encode/engine_adapters/media_convert_adapter.rb +372 -0
- data/lib/active_encode/engine_adapters/media_convert_output.rb +104 -0
- data/lib/active_encode/engine_adapters/pass_through_adapter.rb +239 -0
- data/lib/active_encode/engine_adapters/test_adapter.rb +5 -4
- data/lib/active_encode/engine_adapters/zencoder_adapter.rb +3 -2
- data/lib/active_encode/errors.rb +6 -0
- data/lib/active_encode/global_id.rb +2 -1
- data/lib/active_encode/input.rb +3 -2
- data/lib/active_encode/output.rb +3 -2
- data/lib/active_encode/persistence.rb +11 -5
- data/lib/active_encode/polling.rb +3 -2
- data/lib/active_encode/spec/shared_specs.rb +2 -0
- data/{spec/shared_specs/engine_adapter_specs.rb → lib/active_encode/spec/shared_specs/engine_adapter.rb} +37 -38
- data/lib/active_encode/status.rb +1 -0
- data/lib/active_encode/technical_metadata.rb +3 -2
- data/lib/active_encode/version.rb +2 -1
- data/lib/file_locator.rb +93 -0
- data/spec/controllers/encode_record_controller_spec.rb +53 -0
- data/spec/fixtures/ffmpeg/cancelled-id/cancelled +0 -0
- data/spec/fixtures/file with space.low.mp4 +0 -0
- data/spec/fixtures/file with space.mp4 +0 -0
- data/spec/fixtures/fireworks.low.mp4 +0 -0
- data/spec/fixtures/media_convert/endpoints.json +1 -0
- data/spec/fixtures/media_convert/job_canceled.json +412 -0
- data/spec/fixtures/media_convert/job_canceling.json +1 -0
- data/spec/fixtures/media_convert/job_completed.json +359 -0
- data/spec/fixtures/media_convert/job_completed_detail.json +1 -0
- data/spec/fixtures/media_convert/job_completed_detail_query.json +1 -0
- data/spec/fixtures/media_convert/job_created.json +408 -0
- data/spec/fixtures/media_convert/job_failed.json +406 -0
- data/spec/fixtures/media_convert/job_progressing.json +414 -0
- data/spec/fixtures/pass_through/cancelled-id/cancelled +0 -0
- data/spec/fixtures/pass_through/cancelled-id/input_metadata +90 -0
- data/spec/fixtures/pass_through/completed-id/completed +0 -0
- data/spec/fixtures/pass_through/completed-id/input_metadata +102 -0
- data/spec/fixtures/pass_through/completed-id/output_metadata-high +90 -0
- data/spec/fixtures/pass_through/completed-id/output_metadata-low +90 -0
- data/spec/fixtures/pass_through/completed-id/video-high.mp4 +0 -0
- data/spec/fixtures/pass_through/completed-id/video-low.mp4 +0 -0
- data/spec/fixtures/pass_through/failed-id/error.log +1 -0
- data/spec/fixtures/pass_through/failed-id/input_metadata +90 -0
- data/spec/fixtures/pass_through/running-id/input_metadata +90 -0
- data/spec/integration/elastic_transcoder_adapter_spec.rb +63 -29
- data/spec/integration/ffmpeg_adapter_spec.rb +96 -24
- data/spec/integration/matterhorn_adapter_spec.rb +45 -44
- data/spec/integration/media_convert_adapter_spec.rb +126 -0
- data/spec/integration/pass_through_adapter_spec.rb +151 -0
- data/spec/integration/zencoder_adapter_spec.rb +210 -209
- data/spec/rails_helper.rb +1 -0
- data/spec/routing/encode_record_controller_routing_spec.rb +10 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +13 -12
- data/spec/units/callbacks_spec.rb +3 -2
- data/spec/units/core_spec.rb +26 -25
- data/spec/units/engine_adapter_spec.rb +1 -0
- data/spec/units/file_locator_spec.rb +129 -0
- data/spec/units/global_id_spec.rb +12 -11
- data/spec/units/input_spec.rb +8 -5
- data/spec/units/output_spec.rb +8 -5
- data/spec/units/persistence_spec.rb +15 -11
- data/spec/units/polling_job_spec.rb +7 -6
- data/spec/units/polling_spec.rb +1 -0
- data/spec/units/status_spec.rb +3 -3
- metadata +184 -18
- data/.travis.yml +0 -19
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'rubyhorn'
|
3
|
-
require 'shared_specs
|
4
|
+
require 'active_encode/spec/shared_specs'
|
4
5
|
|
5
6
|
describe ActiveEncode::EngineAdapters::MatterhornAdapter do
|
6
7
|
before(:all) do
|
@@ -26,13 +27,13 @@ describe ActiveEncode::EngineAdapters::MatterhornAdapter do
|
|
26
27
|
let(:created_job) { ActiveEncode::Base.create(file) }
|
27
28
|
let(:running_job) { ActiveEncode::Base.find('running-id') }
|
28
29
|
let(:canceled_job) { ActiveEncode::Base.find('cancelled-id') }
|
29
|
-
let(:cancelling_job) { ActiveEncode::Base.find('running-id')}
|
30
|
+
let(:cancelling_job) { ActiveEncode::Base.find('running-id') }
|
30
31
|
let(:completed_job) { ActiveEncode::Base.find('completed-id') }
|
31
32
|
let(:failed_job) { ActiveEncode::Base.find('failed-id') }
|
32
33
|
|
33
|
-
let(:completed_output) { [{ id: "track-7", checksum: "77de9765545ef63d2c21f7557ead6176", duration: 6337, audio_codec: "AAC", audio_bitrate:
|
34
|
-
let(:completed_tech_metadata) { {
|
35
|
-
let(:failed_tech_metadata) { { checksum: "7ae24368ccb7a6c6422a14ff73f33c9a", duration: 6314, audio_codec: "AAC", audio_bitrate:
|
34
|
+
let(:completed_output) { [{ id: "track-7", checksum: "77de9765545ef63d2c21f7557ead6176", duration: 6337, audio_codec: "AAC", audio_bitrate: 76_502.0, video_codec: "AVC", video_bitrate: 2_000_000.0, frame_rate: 30.0, width: 1308, height: 720, url: "file:///home/cjcolvar/Code/avalon/avalon/red5/webapps/avalon/streams/f564d9de-9c35-4b74-95f0-f3013f32cc1a/b09c765f-b64e-4725-a863-736af66b688c/videoshort.mp4", label: "quality-high" }, { id: "track-8", checksum: "10e13cf51bf8a973011eec6a17ea47ff", duration: 6337, audio_codec: "AAC", audio_bitrate: 76_502.0, video_codec: "AVC", video_bitrate: 500_000.0, frame_rate: 30.0, width: 654, height: 360, url: "file:///home/cjcolvar/Code/avalon/avalon/red5/webapps/avalon/streams/f564d9de-9c35-4b74-95f0-f3013f32cc1a/8d5cd8a9-ad0e-484a-96f0-05e26a84a8f0/videoshort.mp4", label: "quality-low" }, { id: "track-9", checksum: "f2b16a2606dc76cb53c7017f0e166204", duration: 6337, audio_codec: "AAC", audio_bitrate: 76_502.0, video_codec: "AVC", video_bitrate: 1_000_000.0, frame_rate: 30.0, width: 872, height: 480, url: "file:///home/cjcolvar/Code/avalon/avalon/red5/webapps/avalon/streams/f564d9de-9c35-4b74-95f0-f3013f32cc1a/0f81d426-0e26-4496-8f58-c675c86e6f4e/videoshort.mp4", label: "quality-medium" }] }
|
35
|
+
let(:completed_tech_metadata) { {} }
|
36
|
+
let(:failed_tech_metadata) { { checksum: "7ae24368ccb7a6c6422a14ff73f33c9a", duration: 6314, audio_codec: "AAC", audio_bitrate: 171_030.0, video_codec: "AVC", video_bitrate: 74_477.0, frame_rate: 23.719, width: 200, height: 110 } }
|
36
37
|
let(:failed_errors) { "org.opencastproject.workflow.api.WorkflowOperationException: org.opencastproject.workflow.api.WorkflowOperationException: One of the encoding jobs did not complete successfully" }
|
37
38
|
|
38
39
|
# Enforce generic behavior
|
@@ -41,62 +42,62 @@ describe ActiveEncode::EngineAdapters::MatterhornAdapter do
|
|
41
42
|
describe "#create" do
|
42
43
|
subject { created_job }
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
it { expect(subject.output).to be_empty }
|
46
|
+
it { expect(subject.options).to include(preset: 'full') }
|
46
47
|
end
|
47
48
|
|
48
49
|
describe "#find" do
|
49
50
|
context "a running encode" do
|
50
51
|
subject { running_job }
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
it { expect(subject.options).to include(preset: 'full') }
|
54
|
+
it { expect(subject.output).to be_empty }
|
55
|
+
it { expect(subject.current_operations).to include("Hold for workflow selection") }
|
55
56
|
|
56
57
|
context 'input' do
|
57
58
|
subject { running_job.input }
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
60
|
+
it { expect(subject.width).to be_blank }
|
61
|
+
it { expect(subject.height).to be_blank }
|
62
|
+
it { expect(subject.frame_rate).to be_blank }
|
63
|
+
it { expect(subject.duration).to be_blank }
|
64
|
+
it { expect(subject.file_size).to be_blank }
|
65
|
+
it { expect(subject.checksum).to be_blank }
|
66
|
+
it { expect(subject.audio_codec).to be_blank }
|
67
|
+
it { expect(subject.video_codec).to be_blank }
|
68
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
69
|
+
it { expect(subject.video_bitrate).to be_blank }
|
69
70
|
end
|
70
71
|
end
|
71
72
|
context "a cancelled encode" do
|
72
73
|
subject { canceled_job }
|
73
74
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
it { expect(subject.options).to include(preset: 'full') }
|
76
|
+
it { expect(subject.current_operations).not_to be_empty }
|
77
|
+
it { expect(subject.current_operations).to include("Tagging dublin core catalogs for publishing") }
|
78
|
+
it { expect(subject.updated_at).to be > subject.created_at }
|
78
79
|
end
|
79
80
|
|
80
81
|
context "a completed encode" do
|
81
82
|
subject { completed_job }
|
82
83
|
|
83
|
-
|
84
|
-
|
84
|
+
it { expect(subject.options).to include(preset: 'avalon') }
|
85
|
+
it { expect(subject.current_operations).to include("Cleaning up") }
|
85
86
|
end
|
86
87
|
context "a failed encode" do
|
87
88
|
subject { failed_job }
|
88
89
|
|
89
|
-
|
90
|
-
|
90
|
+
it { expect(subject.options).to include(preset: 'error') }
|
91
|
+
it { expect(subject.current_operations).to include("Cleaning up after failure") }
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
94
95
|
describe "#cancel!" do
|
95
|
-
let(:encode) { ActiveEncode::Base.create(file) }
|
96
96
|
subject { encode.cancel! }
|
97
|
+
let(:encode) { ActiveEncode::Base.create(file) }
|
97
98
|
|
98
99
|
it { is_expected.to be_a ActiveEncode::Base }
|
99
|
-
|
100
|
+
it { expect(subject.id).to eq 'cancelled-id' }
|
100
101
|
it { is_expected.to be_cancelled }
|
101
102
|
end
|
102
103
|
|
@@ -107,24 +108,24 @@ describe ActiveEncode::EngineAdapters::MatterhornAdapter do
|
|
107
108
|
|
108
109
|
subject { running_job.reload }
|
109
110
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
it { expect(subject.output).to be_empty }
|
112
|
+
it { expect(subject.options).to include(preset: 'full') }
|
113
|
+
it { expect(subject.current_operations).to include("Hold for workflow selection") }
|
114
|
+
it { expect(subject.percent_complete).to eq 0.43478260869565216 }
|
114
115
|
|
115
116
|
context 'input' do
|
116
117
|
subject { running_job.reload.input }
|
117
118
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
119
|
+
it { expect(subject.width).to be_blank }
|
120
|
+
it { expect(subject.height).to be_blank }
|
121
|
+
it { expect(subject.frame_rate).to be_blank }
|
122
|
+
it { expect(subject.duration).to be_blank }
|
123
|
+
it { expect(subject.file_size).to be_blank }
|
124
|
+
it { expect(subject.checksum).to be_blank }
|
125
|
+
it { expect(subject.audio_codec).to be_blank }
|
126
|
+
it { expect(subject.video_codec).to be_blank }
|
127
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
128
|
+
it { expect(subject.video_bitrate).to be_blank }
|
128
129
|
end
|
129
130
|
end
|
130
131
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'aws-sdk-cloudwatchevents'
|
4
|
+
require 'aws-sdk-cloudwatchlogs'
|
5
|
+
require 'aws-sdk-mediaconvert'
|
6
|
+
require 'aws-sdk-s3'
|
7
|
+
require 'json'
|
8
|
+
require 'active_encode/spec/shared_specs'
|
9
|
+
require 'active_support/json'
|
10
|
+
require 'active_support/time'
|
11
|
+
|
12
|
+
def with_json_parsing
|
13
|
+
old_settings = { parse_json_times: ActiveSupport.parse_json_times, time_zone: Time.zone }
|
14
|
+
ActiveSupport.parse_json_times = true
|
15
|
+
Time.zone = 'America/Chicago'
|
16
|
+
yield
|
17
|
+
ensure
|
18
|
+
ActiveSupport.parse_json_times = old_settings[:parse_json_times]
|
19
|
+
Time.zone = old_settings[:time_zone]
|
20
|
+
end
|
21
|
+
|
22
|
+
def reconstitute_response(fixture_path)
|
23
|
+
with_json_parsing do
|
24
|
+
HashWithIndifferentAccess.new(ActiveSupport::JSON.decode(File.read(File.join("spec/fixtures", fixture_path))))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ActiveEncode::EngineAdapters::MediaConvertAdapter do
|
29
|
+
around do |example|
|
30
|
+
# Setting this before each test works around a stubbing + memoization limitation
|
31
|
+
ActiveEncode::Base.engine_adapter = :media_convert
|
32
|
+
ActiveEncode::Base.engine_adapter.role = 'arn:aws:iam::123456789012:role/service-role/MediaConvert_Default_Role'
|
33
|
+
ActiveEncode::Base.engine_adapter.output_bucket = 'output-bucket'
|
34
|
+
example.run
|
35
|
+
ActiveEncode::Base.engine_adapter = :test
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:job_id) { "1625859001514-vvqfwj" }
|
39
|
+
let(:mediaconvert) { Aws::MediaConvert::Client.new(stub_responses: true) }
|
40
|
+
let(:cloudwatch_events) { Aws::CloudWatchEvents::Client.new(stub_responses: true) }
|
41
|
+
let(:cloudwatch_logs) { Aws::CloudWatchLogs::Client.new(stub_responses: true) }
|
42
|
+
|
43
|
+
before do
|
44
|
+
mediaconvert.stub_responses(:describe_endpoints, reconstitute_response("media_convert/endpoints.json"))
|
45
|
+
|
46
|
+
allow(Aws::MediaConvert::Client).to receive(:new).and_return(mediaconvert)
|
47
|
+
allow(Aws::CloudWatchEvents::Client).to receive(:new).and_return(cloudwatch_events)
|
48
|
+
allow(Aws::CloudWatchLogs::Client).to receive(:new).and_return(cloudwatch_logs)
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:created_job) do
|
52
|
+
mediaconvert.stub_responses(:create_job, reconstitute_response("media_convert/job_created.json"))
|
53
|
+
|
54
|
+
ActiveEncode::Base.create(
|
55
|
+
"s3://input-bucket/test_files/source_file.mp4",
|
56
|
+
output_prefix: "active-encode-test/output",
|
57
|
+
outputs: [
|
58
|
+
{ preset: "System-Avc_16x9_1080p_29_97fps_8500kbps", modifier: "-1080" },
|
59
|
+
{ preset: "System-Avc_16x9_720p_29_97fps_5000kbps", modifier: "-720" },
|
60
|
+
{ preset: "System-Avc_16x9_540p_29_97fps_3500kbps", modifier: "-540" }
|
61
|
+
],
|
62
|
+
use_original_url: true
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:running_job) do
|
67
|
+
mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_progressing.json"))
|
68
|
+
ActiveEncode::Base.find(job_id)
|
69
|
+
end
|
70
|
+
|
71
|
+
let(:canceled_job) do
|
72
|
+
mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_canceled.json"))
|
73
|
+
ActiveEncode::Base.find(job_id)
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:cancelling_job) do
|
77
|
+
mediaconvert.stub_responses(:cancel_job, reconstitute_response("media_convert/job_canceling.json"))
|
78
|
+
mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_canceled.json"))
|
79
|
+
ActiveEncode::Base.find(job_id)
|
80
|
+
end
|
81
|
+
|
82
|
+
let(:completed_job) do
|
83
|
+
mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_completed.json"))
|
84
|
+
cloudwatch_logs.stub_responses(:start_query, reconstitute_response("media_convert/job_completed_detail_query.json"))
|
85
|
+
cloudwatch_logs.stub_responses(:get_query_results, reconstitute_response("media_convert/job_completed_detail.json"))
|
86
|
+
|
87
|
+
ActiveEncode::Base.find(job_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:failed_job) do
|
91
|
+
mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_failed.json"))
|
92
|
+
|
93
|
+
ActiveEncode::Base.find(job_id)
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:completed_output) do
|
97
|
+
[
|
98
|
+
{ id: "1625859001514-vvqfwj-output-auto", url: "s3://output-bucket/active-encode-test/output.m3u8",
|
99
|
+
label: "output.m3u8", audio_codec: "AAC", duration: 888_020, video_codec: "H_264" },
|
100
|
+
{ id: "1625859001514-vvqfwj-output-1080", url: "s3://output-bucket/active-encode-test/output-1080.m3u8",
|
101
|
+
label: "output-1080.m3u8", audio_bitrate: 128_000, audio_codec: "AAC", duration: 888_020,
|
102
|
+
video_bitrate: 8_500_000, height: 1080, width: 1920, video_codec: "H_264", frame_rate: 29.97 },
|
103
|
+
{ id: "1625859001514-vvqfwj-output-720", url: "s3://output-bucket/active-encode-test/output-720.m3u8",
|
104
|
+
label: "output-720.m3u8", audio_bitrate: 96_000, audio_codec: "AAC", duration: 888_020,
|
105
|
+
video_bitrate: 5_000_000, height: 720, width: 1280, video_codec: "H_264", frame_rate: 29.97 },
|
106
|
+
{ id: "1625859001514-vvqfwj-output-540", url: "s3://output-bucket/active-encode-test/output-540.m3u8",
|
107
|
+
label: "output-540.m3u8", audio_bitrate: 96_000, audio_codec: "AAC", duration: 888_020,
|
108
|
+
video_bitrate: 3_500_000, height: 540, width: 960, video_codec: "H_264", frame_rate: 29.97 }
|
109
|
+
]
|
110
|
+
end
|
111
|
+
let(:completed_tech_metadata) { {} }
|
112
|
+
let(:failed_tech_metadata) { {} }
|
113
|
+
|
114
|
+
it_behaves_like "an ActiveEncode::EngineAdapter"
|
115
|
+
|
116
|
+
describe "output" do
|
117
|
+
it "contains all expected outputs" do
|
118
|
+
completed_output.each do |expected_output|
|
119
|
+
found_output = completed_job.output.find { |output| output.id == expected_output[:id] }
|
120
|
+
expected_output.each_pair do |key, value|
|
121
|
+
expect(found_output.send(key)).to eq(value)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'rails_helper'
|
3
|
+
require 'active_encode/spec/shared_specs'
|
4
|
+
|
5
|
+
describe ActiveEncode::EngineAdapters::PassThroughAdapter do
|
6
|
+
around do |example|
|
7
|
+
ActiveEncode::Base.engine_adapter = :pass_through
|
8
|
+
|
9
|
+
Dir.mktmpdir do |dir|
|
10
|
+
@dir = dir
|
11
|
+
example.run
|
12
|
+
Dir.foreach(dir) do |e|
|
13
|
+
next if e == "." || e == ".."
|
14
|
+
FileUtils.rm_rf(File.join(dir, e))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
ActiveEncode::Base.engine_adapter = :test
|
19
|
+
end
|
20
|
+
|
21
|
+
let!(:work_dir) { stub_const "ActiveEncode::EngineAdapters::PassThroughAdapter::WORK_DIR", @dir }
|
22
|
+
let(:file) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'fireworks.mp4').to_s }
|
23
|
+
let(:low_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'fireworks.low.mp4').to_s }
|
24
|
+
let(:created_job) do
|
25
|
+
ActiveEncode::Base.create(file, outputs: [{ label: 'low', url: low_derivative }])
|
26
|
+
end
|
27
|
+
let(:running_job) do
|
28
|
+
created_job
|
29
|
+
end
|
30
|
+
let(:canceled_job) do
|
31
|
+
find_encode 'cancelled-id'
|
32
|
+
end
|
33
|
+
let(:cancelling_job) do
|
34
|
+
find_encode 'running-id'
|
35
|
+
end
|
36
|
+
let(:completed_job) { find_encode "completed-id" }
|
37
|
+
let(:failed_job) { find_encode 'failed-id' }
|
38
|
+
let(:completed_tech_metadata) do
|
39
|
+
{
|
40
|
+
audio_bitrate: 171_030,
|
41
|
+
audio_codec: 'mp4a-40-2',
|
42
|
+
duration: 6315.0,
|
43
|
+
file_size: 199_160,
|
44
|
+
frame_rate: 23.719,
|
45
|
+
height: 110.0,
|
46
|
+
id: "completed-id",
|
47
|
+
url: "/home/pdinh/Downloads/videoshort.mp4",
|
48
|
+
video_bitrate: 74_477,
|
49
|
+
video_codec: 'avc1',
|
50
|
+
width: 200.0
|
51
|
+
}
|
52
|
+
end
|
53
|
+
let(:completed_output) { [{ id: "completed-id" }] }
|
54
|
+
let(:failed_tech_metadata) { {} }
|
55
|
+
|
56
|
+
it_behaves_like "an ActiveEncode::EngineAdapter"
|
57
|
+
|
58
|
+
def find_encode(id)
|
59
|
+
# Precreate ffmpeg output directory and files
|
60
|
+
FileUtils.copy_entry "spec/fixtures/pass_through/#{id}", "#{work_dir}/#{id}"
|
61
|
+
|
62
|
+
# Simulate that progress is modified later than other files
|
63
|
+
sleep 0.1
|
64
|
+
FileUtils.touch Dir.glob("#{work_dir}/#{id}/*.mp4")
|
65
|
+
touch_fixture(id, "completed")
|
66
|
+
touch_fixture(id, "cancelled")
|
67
|
+
touch_fixture(id, "error.log")
|
68
|
+
|
69
|
+
# Stub out system calls
|
70
|
+
allow_any_instance_of(ActiveEncode::EngineAdapters::PassThroughAdapter).to receive(:`).and_return(1234)
|
71
|
+
|
72
|
+
ActiveEncode::Base.find(id)
|
73
|
+
end
|
74
|
+
|
75
|
+
def touch_fixture(id, filename)
|
76
|
+
FileUtils.touch("#{work_dir}/#{id}/#{filename}") if File.exist? "#{work_dir}/#{id}/#{filename}"
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "#create" do
|
80
|
+
subject { created_job }
|
81
|
+
|
82
|
+
it "creates a directory whose name is the encode id" do
|
83
|
+
expect(File).to exist("#{work_dir}/#{subject.id}")
|
84
|
+
end
|
85
|
+
|
86
|
+
context "input file exists" do
|
87
|
+
it "has the input technical metadata in a file" do
|
88
|
+
expect(File.read("#{work_dir}/#{subject.id}/input_metadata")).not_to be_empty
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "input file doesn't exist" do
|
93
|
+
let(:missing_file) { "file:///a_bogus_file.mp4" }
|
94
|
+
let(:missing_job) { ActiveEncode::Base.create(missing_file, outputs: [{ label: "low", url: 'mp4' }]) }
|
95
|
+
|
96
|
+
it "returns the encode with correct error" do
|
97
|
+
expect(missing_job.errors).to include("#{missing_file} does not exist or is not accessible")
|
98
|
+
expect(missing_job.percent_complete).to be 1
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "input file is not media" do
|
103
|
+
let(:nonmedia_file) { "file://" + Rails.root.join('Gemfile').to_s }
|
104
|
+
let(:nonmedia_job) { ActiveEncode::Base.create(nonmedia_file, outputs: [{ label: "low", url: nonmedia_file }]) }
|
105
|
+
|
106
|
+
it "returns the encode with correct error" do
|
107
|
+
expect(nonmedia_job.errors).to include("Error inspecting input: #{nonmedia_file}")
|
108
|
+
expect(nonmedia_job.percent_complete).to be 1
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "input filename with spaces" do
|
113
|
+
let(:file_with_space) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.mp4').to_s }
|
114
|
+
let(:file_with_space_derivative) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.low.mp4').to_s }
|
115
|
+
let!(:create_space_job) { ActiveEncode::Base.create(file_with_space, outputs: [{ label: "low", url: file_with_space_derivative }]) }
|
116
|
+
let(:find_space_job) { ActiveEncode::Base.find create_space_job.id }
|
117
|
+
|
118
|
+
it "does not have errors" do
|
119
|
+
expect(find_space_job.errors).to be_empty
|
120
|
+
end
|
121
|
+
|
122
|
+
it "has the input technical metadata in a file" do
|
123
|
+
expect(File.read("#{work_dir}/#{create_space_job.id}/input_metadata")).not_to be_empty
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'when uri encoded' do
|
127
|
+
let(:file_with_space) { URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.mp4').to_s) }
|
128
|
+
let(:file_with_space_derivative) { URI.encode("file://" + Rails.root.join('..', 'spec', 'fixtures', 'file with space.low.mp4').to_s) }
|
129
|
+
|
130
|
+
it "does not have errors" do
|
131
|
+
expect(find_space_job.errors).to be_empty
|
132
|
+
end
|
133
|
+
|
134
|
+
it "has the input technical metadata in a file" do
|
135
|
+
expect(File.read("#{work_dir}/#{create_space_job.id}/input_metadata")).not_to be_empty
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when failed' do
|
141
|
+
subject { created_job }
|
142
|
+
|
143
|
+
before do
|
144
|
+
allow_any_instance_of(Object).to receive(:`).and_raise Errno::ENOENT
|
145
|
+
end
|
146
|
+
|
147
|
+
it { is_expected.to be_failed }
|
148
|
+
it { expect(subject.errors).to be_present }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'zencoder'
|
3
4
|
require 'json'
|
@@ -24,66 +25,66 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
24
25
|
allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
|
25
26
|
end
|
26
27
|
|
28
|
+
subject { ActiveEncode::Base.create(file) }
|
27
29
|
let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_create.json'))) }
|
28
30
|
let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_create.json'))) }
|
29
31
|
let(:create_output) { [{ id: "511404522", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150610/c09b61e4d130ddf923f0653418a80b9c/399ae101c3f99b4f318635e78a4e587a.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=GY/9LMkQAiDOrMQwS5BkmOE200s%3D&Expires=1434033527", label: nil }] }
|
30
32
|
|
31
|
-
subject { ActiveEncode::Base.create(file) }
|
32
33
|
it { is_expected.to be_a ActiveEncode::Base }
|
33
|
-
|
34
|
+
it { expect(subject.id).not_to be_empty }
|
34
35
|
it { is_expected.to be_running }
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
# it { expect(subject.output).to eq create_output }
|
37
|
+
it { expect(subject.current_operations).to be_empty }
|
38
|
+
it { expect(subject.percent_complete).to eq 0 }
|
39
|
+
it { expect(subject.errors).to be_empty }
|
40
|
+
it { expect(subject.created_at).to eq '2015-06-10T14:38:47Z' }
|
41
|
+
it { expect(subject.updated_at).to eq '2015-06-10T14:38:47Z' }
|
41
42
|
|
42
43
|
context 'input' do
|
43
44
|
subject { ActiveEncode::Base.create(file).input }
|
44
45
|
|
45
46
|
it { is_expected.to be_a ActiveEncode::Input }
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
47
|
+
it { expect(subject.id).to eq "166179248" }
|
48
|
+
it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
|
49
|
+
it { expect(subject.width).to be_blank }
|
50
|
+
it { expect(subject.height).to be_blank }
|
51
|
+
it { expect(subject.frame_rate).to be_blank }
|
52
|
+
it { expect(subject.duration).to be_blank }
|
53
|
+
it { expect(subject.file_size).to be_blank }
|
54
|
+
it { expect(subject.checksum).to be_blank }
|
55
|
+
it { expect(subject.audio_codec).to be_blank }
|
56
|
+
it { expect(subject.video_codec).to be_blank }
|
57
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
58
|
+
it { expect(subject.video_bitrate).to be_blank }
|
59
|
+
it { expect(subject.state).to eq :running }
|
60
|
+
it { expect(subject.created_at).to eq "2015-06-10T14:38:47Z" }
|
61
|
+
it { expect(subject.updated_at).to eq "2015-06-10T14:38:00Z" }
|
61
62
|
end
|
62
63
|
|
63
64
|
context 'output' do
|
64
|
-
let(:output) { ActiveEncode::Base.find('166019107').reload.output }
|
65
65
|
subject { output.first }
|
66
|
+
let(:output) { ActiveEncode::Base.find('166019107').reload.output }
|
66
67
|
|
67
68
|
it 'is an array' do
|
68
69
|
expect(output).to be_a Array
|
69
70
|
end
|
70
71
|
it { is_expected.to be_a ActiveEncode::Output }
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
72
|
+
it { expect(subject.id).to eq "511404522" }
|
73
|
+
it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150610/c09b61e4d130ddf923f0653418a80b9c/399ae101c3f99b4f318635e78a4e587a.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=GY/9LMkQAiDOrMQwS5BkmOE200s%3D&Expires=1434033527" }
|
74
|
+
it { expect(subject.label).to be_blank }
|
75
|
+
it { expect(subject.width).to be_blank }
|
76
|
+
it { expect(subject.height).to be_blank }
|
77
|
+
it { expect(subject.frame_rate).to be_blank }
|
78
|
+
it { expect(subject.duration).to be_blank }
|
79
|
+
it { expect(subject.file_size).to be_blank }
|
80
|
+
it { expect(subject.checksum).to be_blank }
|
81
|
+
it { expect(subject.audio_codec).to be_blank }
|
82
|
+
it { expect(subject.video_codec).to be_blank }
|
83
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
84
|
+
it { expect(subject.video_bitrate).to be_blank }
|
85
|
+
it { expect(subject.state).to eq :running }
|
86
|
+
it { expect(subject.created_at).to eq "2015-06-10T14:38:47Z" }
|
87
|
+
it { expect(subject.updated_at).to eq "2015-06-10T14:38:47Z" }
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
@@ -94,208 +95,208 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
94
95
|
end
|
95
96
|
|
96
97
|
context "a running encode" do
|
98
|
+
subject { ActiveEncode::Base.find('166019107') }
|
97
99
|
let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_running.json'))) }
|
98
100
|
let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_running.json'))) }
|
99
101
|
# let(:running_output) { [{ id: "510582971", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106", label: nil }] }
|
100
102
|
# let(:running_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }
|
101
103
|
|
102
|
-
subject { ActiveEncode::Base.find('166019107') }
|
103
104
|
it { is_expected.to be_a ActiveEncode::Base }
|
104
|
-
|
105
|
+
it { expect(subject.id).to eq '166019107' }
|
105
106
|
it { is_expected.to be_running }
|
106
|
-
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
#
|
107
|
+
# it { expect(subject.output).to eq running_output }
|
108
|
+
it { expect(subject.current_operations).to be_empty }
|
109
|
+
it { expect(subject.percent_complete).to eq 30.0 }
|
110
|
+
it { expect(subject.errors).to be_empty }
|
111
|
+
it { expect(subject.created_at).to eq '2015-06-09T16:18:26Z' }
|
112
|
+
it { expect(subject.updated_at).to eq '2015-06-09T16:18:28Z' }
|
113
|
+
|
114
|
+
# it { expect(subject.tech_metadata).to eq running_tech_metadata }
|
114
115
|
context 'input' do
|
115
116
|
subject { ActiveEncode::Base.find('166019107').input }
|
116
117
|
|
117
118
|
it { is_expected.to be_a ActiveEncode::Input }
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
119
|
+
it { expect(subject.id).to eq "165990056" }
|
120
|
+
it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
|
121
|
+
it { expect(subject.width).to eq 320 }
|
122
|
+
it { expect(subject.height).to eq 240 }
|
123
|
+
it { expect(subject.frame_rate).to eq 29.97 }
|
124
|
+
it { expect(subject.duration).to eq 57_992 }
|
125
|
+
it { expect(subject.file_size).to be_blank }
|
126
|
+
it { expect(subject.checksum).to be_blank }
|
127
|
+
it { expect(subject.audio_codec).to eq "aac" }
|
128
|
+
it { expect(subject.video_codec).to eq "h264" }
|
129
|
+
it { expect(subject.audio_bitrate).to eq 52 }
|
130
|
+
it { expect(subject.video_bitrate).to eq 535 }
|
131
|
+
it { expect(subject.state).to eq :completed }
|
132
|
+
it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
|
133
|
+
it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
|
133
134
|
end
|
134
135
|
|
135
136
|
context 'output' do
|
136
|
-
let(:output) { ActiveEncode::Base.find('166019107').output }
|
137
137
|
subject { output.first }
|
138
|
+
let(:output) { ActiveEncode::Base.find('166019107').output }
|
138
139
|
|
139
140
|
it 'is an array' do
|
140
141
|
expect(output).to be_a Array
|
141
142
|
end
|
142
143
|
it { is_expected.to be_a ActiveEncode::Output }
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
144
|
+
it { expect(subject.id).to eq "510582971" }
|
145
|
+
it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
|
146
|
+
it { expect(subject.label).to be_blank }
|
147
|
+
it { expect(subject.width).to be_blank }
|
148
|
+
it { expect(subject.height).to be_blank }
|
149
|
+
it { expect(subject.frame_rate).to be_blank }
|
150
|
+
it { expect(subject.duration).to be_blank }
|
151
|
+
it { expect(subject.file_size).to be_blank }
|
152
|
+
it { expect(subject.checksum).to be_blank }
|
153
|
+
it { expect(subject.audio_codec).to be_blank }
|
154
|
+
it { expect(subject.video_codec).to be_blank }
|
155
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
156
|
+
it { expect(subject.video_bitrate).to be_blank }
|
157
|
+
it { expect(subject.state).to eq :running }
|
158
|
+
it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
|
159
|
+
it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
|
159
160
|
end
|
160
161
|
end
|
161
162
|
|
162
163
|
context "a cancelled encode" do
|
164
|
+
subject { ActiveEncode::Base.find('165866551') }
|
163
165
|
let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_cancelled.json'))) }
|
164
166
|
let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_cancelled.json'))) }
|
165
167
|
|
166
|
-
subject { ActiveEncode::Base.find('165866551') }
|
167
168
|
it { is_expected.to be_a ActiveEncode::Base }
|
168
|
-
|
169
|
+
it { expect(subject.id).to eq '165866551' }
|
169
170
|
it { is_expected.to be_cancelled }
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
it { expect(subject.current_operations).to be_empty }
|
172
|
+
it { expect(subject.percent_complete).to eq 0 }
|
173
|
+
it { expect(subject.errors).to be_empty }
|
174
|
+
it { expect(subject.created_at).to eq '2015-06-08T20:43:23Z' }
|
175
|
+
it { expect(subject.updated_at).to eq '2015-06-08T20:43:26Z' }
|
175
176
|
|
176
177
|
context 'input' do
|
177
178
|
subject { ActiveEncode::Base.find('165866551').input }
|
178
179
|
|
179
180
|
it { is_expected.to be_a ActiveEncode::Input }
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
181
|
+
it { expect(subject.id).to eq "165837500" }
|
182
|
+
it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
|
183
|
+
it { expect(subject.width).to be_blank }
|
184
|
+
it { expect(subject.height).to be_blank }
|
185
|
+
it { expect(subject.frame_rate).to be_blank }
|
186
|
+
it { expect(subject.duration).to be_blank }
|
187
|
+
it { expect(subject.file_size).to be_blank }
|
188
|
+
it { expect(subject.checksum).to be_blank }
|
189
|
+
it { expect(subject.audio_codec).to be_blank }
|
190
|
+
it { expect(subject.video_codec).to be_blank }
|
191
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
192
|
+
it { expect(subject.video_bitrate).to be_blank }
|
193
|
+
it { expect(subject.state).to eq :cancelled }
|
194
|
+
it { expect(subject.created_at).to eq "2015-06-08T20:43:23Z" }
|
195
|
+
it { expect(subject.updated_at).to eq "2015-06-08T20:43:26Z" }
|
195
196
|
end
|
196
197
|
end
|
197
198
|
|
198
199
|
context "a completed encode" do
|
200
|
+
subject { ActiveEncode::Base.find('165839139') }
|
199
201
|
let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_completed.json'))) }
|
200
202
|
let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_completed.json'))) }
|
201
203
|
let(:completed_output) { { id: "509856876", audio_bitrate: "53", audio_codec: "aac", audio_channels: "2", duration: "5000", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "549", video_codec: "h264", width: "320", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150608/ebbe865f8ef1b960d7c2bb0663b88a12/0f1948dcb2fd701fba30ff21908fe460.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=1LgIyl/el9E7zeyPxzd/%2BNwez6Y%3D&Expires=1433873646", label: nil } }
|
202
204
|
# let(:completed_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }
|
203
205
|
|
204
|
-
subject { ActiveEncode::Base.find('165839139') }
|
205
206
|
it { is_expected.to be_a ActiveEncode::Base }
|
206
|
-
|
207
|
+
it { expect(subject.id).to eq '165839139' }
|
207
208
|
it { is_expected.to be_completed }
|
208
|
-
#
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
209
|
+
# it { expect(subject.output).to include completed_output }
|
210
|
+
it { expect(subject.current_operations).to be_empty }
|
211
|
+
it { expect(subject.percent_complete).to eq 100 }
|
212
|
+
it { expect(subject.errors).to be_empty }
|
213
|
+
it { expect(subject.created_at).to eq '2015-06-08T18:13:53Z' }
|
214
|
+
it { expect(subject.updated_at).to eq '2015-06-08T18:14:06Z' }
|
214
215
|
|
215
216
|
context 'input' do
|
216
217
|
subject { ActiveEncode::Base.find('165839139').input }
|
217
218
|
|
218
219
|
it { is_expected.to be_a ActiveEncode::Input }
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
220
|
+
it { expect(subject.id).to eq "165810088" }
|
221
|
+
it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
|
222
|
+
it { expect(subject.width).to eq 320 }
|
223
|
+
it { expect(subject.height).to eq 240 }
|
224
|
+
it { expect(subject.frame_rate).to eq 29.97 }
|
225
|
+
it { expect(subject.duration).to eq 57_992 }
|
226
|
+
it { expect(subject.file_size).to be_blank }
|
227
|
+
it { expect(subject.checksum).to be_blank }
|
228
|
+
it { expect(subject.audio_codec).to eq "aac" }
|
229
|
+
it { expect(subject.video_codec).to eq "h264" }
|
230
|
+
it { expect(subject.audio_bitrate).to eq 52 }
|
231
|
+
it { expect(subject.video_bitrate).to eq 535 }
|
232
|
+
it { expect(subject.state).to eq :completed }
|
233
|
+
it { expect(subject.created_at).to eq "2015-06-08T18:13:53Z" }
|
234
|
+
it { expect(subject.updated_at).to eq "2015-06-08T18:14:06Z" }
|
234
235
|
end
|
235
236
|
|
236
237
|
context 'output' do
|
237
|
-
let(:output) { ActiveEncode::Base.find('166019107').reload.output }
|
238
238
|
subject { output.first }
|
239
|
+
let(:output) { ActiveEncode::Base.find('166019107').reload.output }
|
239
240
|
|
240
241
|
it 'is an array' do
|
241
242
|
expect(output).to be_a Array
|
242
243
|
end
|
243
244
|
it { is_expected.to be_a ActiveEncode::Output }
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
245
|
+
it { expect(subject.id).to eq "509856876" }
|
246
|
+
it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150608/ebbe865f8ef1b960d7c2bb0663b88a12/0f1948dcb2fd701fba30ff21908fe460.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=1LgIyl/el9E7zeyPxzd/%2BNwez6Y%3D&Expires=1433873646" }
|
247
|
+
it { expect(subject.label).to be_blank }
|
248
|
+
it { expect(subject.width).to eq 320 }
|
249
|
+
it { expect(subject.height).to eq 240 }
|
250
|
+
it { expect(subject.frame_rate).to eq 29.97 }
|
251
|
+
it { expect(subject.duration).to eq 5000 }
|
252
|
+
it { expect(subject.file_size).to be_blank }
|
253
|
+
it { expect(subject.checksum).to be_blank }
|
254
|
+
it { expect(subject.audio_codec).to eq "aac" }
|
255
|
+
it { expect(subject.video_codec).to eq "h264" }
|
256
|
+
it { expect(subject.audio_bitrate).to eq 53 }
|
257
|
+
it { expect(subject.video_bitrate).to eq 549 }
|
258
|
+
it { expect(subject.state).to eq :completed }
|
259
|
+
it { expect(subject.created_at).to eq "2015-06-08T18:13:53Z" }
|
260
|
+
it { expect(subject.updated_at).to eq "2015-06-08T18:14:06Z" }
|
260
261
|
end
|
261
262
|
end
|
262
263
|
|
263
264
|
context "a failed encode" do
|
265
|
+
subject { ActiveEncode::Base.find('166079902') }
|
264
266
|
let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_failed.json'))) }
|
265
267
|
let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_failed.json'))) }
|
266
268
|
let(:failed_tech_metadata) { { mime_type: "video/mp4", checksum: "7ae24368ccb7a6c6422a14ff73f33c9a", duration: "6314", audio_codec: "AAC", audio_channels: "2", audio_bitrate: "171030.0", video_codec: "AVC", video_bitrate: "74477.0", video_framerate: "23.719", width: "200", height: "110" } }
|
267
269
|
let(:failed_errors) { "The file is an XML file, and doesn't contain audio or video tracks." }
|
268
270
|
|
269
|
-
subject { ActiveEncode::Base.find('166079902') }
|
270
271
|
it { is_expected.to be_a ActiveEncode::Base }
|
271
|
-
|
272
|
+
it { expect(subject.id).to eq '166079902' }
|
272
273
|
it { is_expected.to be_failed }
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
274
|
+
it { expect(subject.current_operations).to be_empty }
|
275
|
+
it { expect(subject.percent_complete).to eq 0 }
|
276
|
+
it { expect(subject.errors).to be_empty }
|
277
|
+
it { expect(subject.created_at).to eq '2015-06-09T20:52:57Z' }
|
278
|
+
it { expect(subject.updated_at).to eq '2015-06-09T20:53:00Z' }
|
278
279
|
|
279
280
|
context 'input' do
|
280
281
|
subject { ActiveEncode::Base.find('165866551').input }
|
281
282
|
|
282
283
|
it { is_expected.to be_a ActiveEncode::Input }
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
284
|
+
it { expect(subject.id).to eq "166050851" }
|
285
|
+
it { expect(subject.url).to eq "s3://zencoder-customer-ingest/uploads/2015-06-09/240330/187007/682c2d90-0eea-11e5-84c9-f158f44c3d50.xml" }
|
286
|
+
it { expect(subject.errors).to include failed_errors }
|
287
|
+
it { expect(subject.width).to be_blank }
|
288
|
+
it { expect(subject.height).to be_blank }
|
289
|
+
it { expect(subject.frame_rate).to be_blank }
|
290
|
+
it { expect(subject.duration).to be_blank }
|
291
|
+
it { expect(subject.file_size).to be_blank }
|
292
|
+
it { expect(subject.checksum).to be_blank }
|
293
|
+
it { expect(subject.audio_codec).to be_blank }
|
294
|
+
it { expect(subject.video_codec).to be_blank }
|
295
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
296
|
+
it { expect(subject.video_bitrate).to be_blank }
|
297
|
+
it { expect(subject.state).to eq :failed }
|
298
|
+
it { expect(subject.created_at).to eq "2015-06-09T20:52:57Z" }
|
299
|
+
it { expect(subject.updated_at).to eq "2015-06-09T20:53:00Z" }
|
299
300
|
end
|
300
301
|
end
|
301
302
|
end
|
@@ -307,14 +308,14 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
307
308
|
allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
|
308
309
|
end
|
309
310
|
|
311
|
+
subject { encode.cancel! }
|
310
312
|
let(:cancel_response) { Zencoder::Response.new(code: 200) } # TODO: check that this is the correct response code for a successful cancel
|
311
313
|
let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_cancelled.json'))) }
|
312
314
|
let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_cancelled.json'))) }
|
313
315
|
|
314
316
|
let(:encode) { ActiveEncode::Base.create(file) }
|
315
|
-
subject { encode.cancel! }
|
316
317
|
it { is_expected.to be_a ActiveEncode::Base }
|
317
|
-
|
318
|
+
it { expect(subject.id).to eq '165866551' }
|
318
319
|
it { is_expected.to be_cancelled }
|
319
320
|
end
|
320
321
|
|
@@ -324,67 +325,67 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
324
325
|
allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
|
325
326
|
end
|
326
327
|
|
328
|
+
subject { ActiveEncode::Base.find('166019107').reload }
|
327
329
|
let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_running.json'))) }
|
328
330
|
let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_running.json'))) }
|
329
331
|
# let(:reload_output) { [{ id: "510582971", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106", label: nil }] }
|
330
332
|
# let(:reload_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }
|
331
333
|
|
332
|
-
subject { ActiveEncode::Base.find('166019107').reload }
|
333
334
|
it { is_expected.to be_a ActiveEncode::Base }
|
334
|
-
|
335
|
+
it { expect(subject.id).to eq '166019107' }
|
335
336
|
it { is_expected.to be_running }
|
336
|
-
#
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
337
|
+
# it { expect(subject.output).to eq reload_output }
|
338
|
+
it { expect(subject.current_operations).to be_empty }
|
339
|
+
it { expect(subject.percent_complete).to eq 30.0 }
|
340
|
+
it { expect(subject.errors).to be_empty }
|
341
|
+
it { expect(subject.created_at).to eq '2015-06-09T16:18:26Z' }
|
342
|
+
it { expect(subject.updated_at).to eq '2015-06-09T16:18:28Z' }
|
342
343
|
|
343
344
|
context 'input' do
|
344
345
|
subject { ActiveEncode::Base.find('166019107').reload.input }
|
345
346
|
|
346
347
|
it { is_expected.to be_a ActiveEncode::Input }
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
348
|
+
it { expect(subject.id).to eq "165990056" }
|
349
|
+
it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
|
350
|
+
it { expect(subject.width).to eq 320 }
|
351
|
+
it { expect(subject.height).to eq 240 }
|
352
|
+
it { expect(subject.frame_rate).to eq 29.97 }
|
353
|
+
it { expect(subject.duration).to eq 57_992 }
|
354
|
+
it { expect(subject.file_size).to be_blank }
|
355
|
+
it { expect(subject.checksum).to be_blank }
|
356
|
+
it { expect(subject.audio_codec).to eq "aac" }
|
357
|
+
it { expect(subject.video_codec).to eq "h264" }
|
358
|
+
it { expect(subject.audio_bitrate).to eq 52 }
|
359
|
+
it { expect(subject.video_bitrate).to eq 535 }
|
360
|
+
it { expect(subject.state).to eq :completed }
|
361
|
+
it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
|
362
|
+
it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
|
362
363
|
end
|
363
364
|
|
364
365
|
context 'output' do
|
365
|
-
let(:output) { ActiveEncode::Base.find('166019107').reload.output }
|
366
366
|
subject { output.first }
|
367
|
+
let(:output) { ActiveEncode::Base.find('166019107').reload.output }
|
367
368
|
|
368
369
|
it 'is an array' do
|
369
370
|
expect(output).to be_a Array
|
370
371
|
end
|
371
372
|
it { is_expected.to be_a ActiveEncode::Output }
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
373
|
+
it { expect(subject.id).to eq "510582971" }
|
374
|
+
it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
|
375
|
+
it { expect(subject.label).to be_blank }
|
376
|
+
it { expect(subject.width).to be_blank }
|
377
|
+
it { expect(subject.height).to be_blank }
|
378
|
+
it { expect(subject.frame_rate).to be_blank }
|
379
|
+
it { expect(subject.duration).to be_blank }
|
380
|
+
it { expect(subject.file_size).to be_blank }
|
381
|
+
it { expect(subject.checksum).to be_blank }
|
382
|
+
it { expect(subject.audio_codec).to be_blank }
|
383
|
+
it { expect(subject.video_codec).to be_blank }
|
384
|
+
it { expect(subject.audio_bitrate).to be_blank }
|
385
|
+
it { expect(subject.video_bitrate).to be_blank }
|
386
|
+
it { expect(subject.state).to eq :running }
|
387
|
+
it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
|
388
|
+
it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
|
388
389
|
end
|
389
390
|
end
|
390
391
|
end
|