active_encode 0.5.0 → 0.6.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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +72 -0
- data/.rubocop.yml +8 -70
- data/.rubocop_todo.yml +64 -0
- data/Gemfile +3 -3
- data/active_encode.gemspec +4 -1
- data/app/controllers/active_encode/encode_record_controller.rb +1 -0
- data/app/jobs/active_encode/polling_job.rb +1 -1
- data/app/models/active_encode/encode_record.rb +1 -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 +1 -0
- 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 +2 -1
- data/lib/active_encode/engine_adapters/elastic_transcoder_adapter.rb +25 -24
- data/lib/active_encode/engine_adapters/ffmpeg_adapter.rb +43 -58
- data/lib/active_encode/engine_adapters/matterhorn_adapter.rb +5 -4
- 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/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 +7 -3
- data/lib/active_encode/polling.rb +2 -1
- 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 +7 -8
- data/spec/controllers/encode_record_controller_spec.rb +2 -1
- data/spec/integration/elastic_transcoder_adapter_spec.rb +26 -26
- data/spec/integration/ffmpeg_adapter_spec.rb +26 -22
- data/spec/integration/matterhorn_adapter_spec.rb +6 -5
- data/spec/integration/zencoder_adapter_spec.rb +15 -14
- data/spec/rails_helper.rb +1 -0
- data/spec/routing/encode_record_controller_routing_spec.rb +1 -0
- data/spec/shared_specs/engine_adapter_specs.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- 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 +9 -8
- data/spec/units/engine_adapter_spec.rb +1 -0
- data/spec/units/file_locator_spec.rb +19 -18
- data/spec/units/global_id_spec.rb +4 -3
- data/spec/units/input_spec.rb +8 -5
- data/spec/units/output_spec.rb +8 -5
- data/spec/units/persistence_spec.rb +8 -4
- 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 +37 -7
- data/.travis.yml +0 -19
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rails_helper'
|
2
3
|
|
3
4
|
describe ActiveEncode::EncodeRecordController, type: :controller, db_clean: true do
|
4
5
|
routes { ActiveEncode::Engine.routes }
|
5
6
|
|
6
|
-
let(:encode_record) { ActiveEncode::EncodeRecord.create(id: 1, global_id: "app://ActiveEncode/Encode/1", state: "running", adapter: "ffmpeg", title: "Test", raw_object: raw_object)}
|
7
|
+
let(:encode_record) { ActiveEncode::EncodeRecord.create(id: 1, global_id: "app://ActiveEncode/Encode/1", state: "running", adapter: "ffmpeg", title: "Test", raw_object: raw_object, progress: 100) }
|
7
8
|
let(:raw_object) do
|
8
9
|
"{\"input\":{\"url\":\"file:///Users/cjcolvar/Documents/Code/samvera/active_encode/spec/fixtures/fireworks.mp4\",\"width\":960.0,\"height\":540.0,\"frame_rate\":29.671,\"duration\":6024,\"file_size\":1629578,\"audio_codec\":\"mp4a-40-2\",\"video_codec\":\"avc1\",\"audio_bitrate\":69737,\"video_bitrate\":2092780,\"created_at\":\"2018-12-17T16:54:50.401-05:00\",\"updated_at\":\"2018-12-17T16:54:50.401-05:00\",\"id\":\"8156\"},\"options\":{},\"id\":\"35efa965-ec51-409d-9495-2ae9669adbcc\",\"output\":[{\"url\":\"file:///Users/cjcolvar/Documents/Code/samvera/active_encode/.internal_test_app/encodes/35efa965-ec51-409d-9495-2ae9669adbcc/outputs/fireworks-low.mp4\",\"label\":\"low\",\"id\":\"8156-low\",\"created_at\":\"2018-12-17T16:54:50.401-05:00\",\"updated_at\":\"2018-12-17T16:54:59.169-05:00\",\"width\":640.0,\"height\":480.0,\"frame_rate\":29.671,\"duration\":6038,\"file_size\":905987,\"audio_codec\":\"mp4a-40-2\",\"video_codec\":\"avc1\",\"audio_bitrate\":72000,\"video_bitrate\":1126859},{\"url\":\"file:///Users/cjcolvar/Documents/Code/samvera/active_encode/.internal_test_app/encodes/35efa965-ec51-409d-9495-2ae9669adbcc/outputs/fireworks-high.mp4\",\"label\":\"high\",\"id\":\"8156-high\",\"created_at\":\"2018-12-17T16:54:50.401-05:00\",\"updated_at\":\"2018-12-17T16:54:59.169-05:00\",\"width\":1280.0,\"height\":720.0,\"frame_rate\":29.671,\"duration\":6038,\"file_size\":2102027,\"audio_codec\":\"mp4a-40-2\",\"video_codec\":\"avc1\",\"audio_bitrate\":72000,\"video_bitrate\":2721866}],\"state\":\"completed\",\"errors\":[],\"created_at\":\"2018-12-17T16:54:50.401-05:00\",\"updated_at\":\"2018-12-17T16:54:59.169-05:00\",\"current_operations\":[],\"percent_complete\":100,\"global_id\":{\"uri\":\"gid://ActiveEncode/Encode/35efa965-ec51-409d-9495-2ae9669adbcc\"}}"
|
9
10
|
end
|
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'aws-sdk'
|
3
4
|
require 'json'
|
4
5
|
require 'shared_specs/engine_adapter_specs'
|
5
6
|
|
6
7
|
describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
7
|
-
around
|
8
|
+
around do |example|
|
8
9
|
# Setting this before each test works around a stubbing + memoization limitation
|
9
10
|
ActiveEncode::Base.engine_adapter = :elastic_transcoder
|
10
11
|
example.run
|
@@ -22,26 +23,27 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
|
22
23
|
let(:created_job) do
|
23
24
|
j = Aws::ElasticTranscoder::Types::Job.new JSON.parse(File.read('spec/fixtures/elastic_transcoder/job_created.json'))
|
24
25
|
j.input = Aws::ElasticTranscoder::Types::JobInput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/input_generic.json')))
|
25
|
-
j.outputs = [
|
26
|
+
j.outputs = [Aws::ElasticTranscoder::Types::JobOutput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/output_submitted.json')))]
|
26
27
|
|
27
28
|
client.stub_responses(:create_job, Aws::ElasticTranscoder::Types::ReadJobResponse.new(job: j))
|
28
29
|
|
29
30
|
ActiveEncode::Base.create(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
"spec/fixtures/fireworks.mp4",
|
32
|
+
pipeline_id: "1471963629141-kmcocm",
|
33
|
+
masterfile_bucket: "BucketName",
|
34
|
+
output_key_prefix: "elastic-transcoder-samples/output/hls/",
|
35
|
+
outputs: [{
|
36
|
+
key: 'hls0400k/' + "e8fe80f5bsomefilesource_bucket7063b12d567b90c0bdf6322116bba11ac458fe9d62921644159fe4a",
|
37
|
+
preset_id: "1351620000001-200050",
|
38
|
+
segment_duration: "2"
|
39
|
+
}]
|
40
|
+
)
|
39
41
|
end
|
40
42
|
|
41
43
|
let(:running_job) do
|
42
44
|
j = Aws::ElasticTranscoder::Types::Job.new JSON.parse(File.read('spec/fixtures/elastic_transcoder/job_progressing.json'))
|
43
45
|
j.input = Aws::ElasticTranscoder::Types::JobInput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/input_progressing.json')))
|
44
|
-
j.outputs = [
|
46
|
+
j.outputs = [Aws::ElasticTranscoder::Types::JobOutput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/output_progressing.json')))]
|
45
47
|
|
46
48
|
client.stub_responses(:read_job, Aws::ElasticTranscoder::Types::ReadJobResponse.new(job: j))
|
47
49
|
ActiveEncode::Base.find('running-id')
|
@@ -50,7 +52,7 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
|
50
52
|
let(:canceled_job) do
|
51
53
|
j = Aws::ElasticTranscoder::Types::Job.new JSON.parse(File.read('spec/fixtures/elastic_transcoder/job_canceled.json'))
|
52
54
|
j.input = Aws::ElasticTranscoder::Types::JobInput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/input_generic.json')))
|
53
|
-
j.outputs = [
|
55
|
+
j.outputs = [Aws::ElasticTranscoder::Types::JobOutput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/output_canceled.json')))]
|
54
56
|
|
55
57
|
client.stub_responses(:read_job, Aws::ElasticTranscoder::Types::ReadJobResponse.new(job: j))
|
56
58
|
|
@@ -60,11 +62,11 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
|
60
62
|
let(:cancelling_job) do
|
61
63
|
j1 = Aws::ElasticTranscoder::Types::Job.new JSON.parse(File.read('spec/fixtures/elastic_transcoder/job_progressing.json'))
|
62
64
|
j1.input = Aws::ElasticTranscoder::Types::JobInput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/input_progressing.json')))
|
63
|
-
j1.outputs = [
|
65
|
+
j1.outputs = [Aws::ElasticTranscoder::Types::JobOutput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/output_progressing.json')))]
|
64
66
|
|
65
67
|
j2 = Aws::ElasticTranscoder::Types::Job.new JSON.parse(File.read('spec/fixtures/elastic_transcoder/job_canceled.json'))
|
66
68
|
j2.input = Aws::ElasticTranscoder::Types::JobInput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/input_generic.json')))
|
67
|
-
j2.outputs = [
|
69
|
+
j2.outputs = [Aws::ElasticTranscoder::Types::JobOutput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/output_canceled.json')))]
|
68
70
|
|
69
71
|
client.stub_responses(:read_job, [Aws::ElasticTranscoder::Types::ReadJobResponse.new(job: j1), Aws::ElasticTranscoder::Types::ReadJobResponse.new(job: j2)])
|
70
72
|
|
@@ -78,7 +80,7 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
|
78
80
|
let(:completed_job) do
|
79
81
|
j = Aws::ElasticTranscoder::Types::Job.new JSON.parse(File.read('spec/fixtures/elastic_transcoder/job_completed.json'))
|
80
82
|
j.input = Aws::ElasticTranscoder::Types::JobInput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/input_completed.json')))
|
81
|
-
j.outputs = [
|
83
|
+
j.outputs = [Aws::ElasticTranscoder::Types::JobOutput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/output_completed.json')))]
|
82
84
|
|
83
85
|
client.stub_responses(:read_job, Aws::ElasticTranscoder::Types::ReadJobResponse.new(job: j))
|
84
86
|
ActiveEncode::Base.find('completed-id')
|
@@ -87,29 +89,28 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
|
87
89
|
let(:failed_job) do
|
88
90
|
j = Aws::ElasticTranscoder::Types::Job.new JSON.parse(File.read('spec/fixtures/elastic_transcoder/job_failed.json'))
|
89
91
|
j.input = Aws::ElasticTranscoder::Types::JobInput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/input_generic.json')))
|
90
|
-
j.outputs = [
|
92
|
+
j.outputs = [Aws::ElasticTranscoder::Types::JobOutput.new(JSON.parse(File.read('spec/fixtures/elastic_transcoder/output_failed.json')))]
|
91
93
|
|
92
94
|
client.stub_responses(:read_job, Aws::ElasticTranscoder::Types::ReadJobResponse.new(job: j))
|
93
95
|
ActiveEncode::Base.find('failed-id')
|
94
96
|
end
|
95
97
|
|
96
|
-
let(:completed_output) { [{ id: "2", url: "s3://BucketName/elastic-transcoder-samples/output/hls/hls0400k/e8fe80f5b7063b12d567b90c0bdf6322116bba11ac458fe9d62921644159fe4a", label: "hls0400k", :
|
97
|
-
let(:completed_tech_metadata) { { :
|
98
|
+
let(:completed_output) { [{ id: "2", url: "s3://BucketName/elastic-transcoder-samples/output/hls/hls0400k/e8fe80f5b7063b12d567b90c0bdf6322116bba11ac458fe9d62921644159fe4a", label: "hls0400k", width: 400, height: 224, frame_rate: 25, file_size: 6_901_104, duration: 117_353 }] }
|
99
|
+
let(:completed_tech_metadata) { { width: 1280, height: 720, frame_rate: 25, file_size: 21_069_678, duration: 117_312 } }
|
98
100
|
let(:failed_tech_metadata) { {} }
|
99
101
|
|
100
102
|
it_behaves_like "an ActiveEncode::EngineAdapter"
|
101
103
|
|
102
104
|
describe "#create" do
|
103
|
-
let(:create_output) { [{ id: "2", url: "s3://BucketName/elastic-transcoder-samples/output/hls/hls0400k/e8fe80f5b7063b12d567b90c0bdf6322116bba11ac458fe9d62921644159fe4a", label: "hls0400k" }] }
|
104
|
-
|
105
105
|
subject { created_job }
|
106
|
+
let(:create_output) { [{ id: "2", url: "s3://BucketName/elastic-transcoder-samples/output/hls/hls0400k/e8fe80f5b7063b12d567b90c0bdf6322116bba11ac458fe9d62921644159fe4a", label: "hls0400k" }] }
|
106
107
|
|
107
108
|
it { is_expected.to be_running }
|
108
109
|
its(:current_operations) { is_expected.to be_empty }
|
109
110
|
|
110
111
|
it 'output has technical metadata' do
|
111
112
|
subject.output.each do |output|
|
112
|
-
expected_output = create_output.find {|expected_out| expected_out[:id] == output.id }
|
113
|
+
expected_output = create_output.find { |expected_out| expected_out[:id] == output.id }
|
113
114
|
expect(output.as_json.symbolize_keys).to include expected_output
|
114
115
|
end
|
115
116
|
end
|
@@ -117,10 +118,9 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
|
117
118
|
|
118
119
|
describe "#find" do
|
119
120
|
context "a running encode" do
|
120
|
-
let(:running_output) { [{ id: "2", url: "s3://BucketName/elastic-transcoder-samples/output/hls/hls0400k/e8fe80f5b7063b12d567b90c0bdf6322116bba11ac458fe9d62921644159fe4a", label: "hls0400k" }] }
|
121
|
-
let(:running_tech_metadata) { {:width=>1280, :height=>720, :frame_rate=>25, :file_size=>21069678, :duration=>117312} }
|
122
|
-
|
123
121
|
subject { running_job }
|
122
|
+
let(:running_output) { [{ id: "2", url: "s3://BucketName/elastic-transcoder-samples/output/hls/hls0400k/e8fe80f5b7063b12d567b90c0bdf6322116bba11ac458fe9d62921644159fe4a", label: "hls0400k" }] }
|
123
|
+
let(:running_tech_metadata) { { width: 1280, height: 720, frame_rate: 25, file_size: 21_069_678, duration: 117_312 } }
|
124
124
|
|
125
125
|
its(:current_operations) { is_expected.to be_empty }
|
126
126
|
|
@@ -130,7 +130,7 @@ describe ActiveEncode::EngineAdapters::ElasticTranscoderAdapter do
|
|
130
130
|
|
131
131
|
it 'output has technical metadata' do
|
132
132
|
subject.output.each do |output|
|
133
|
-
expected_output = running_output.find {|expected_out| expected_out[:id] == output.id }
|
133
|
+
expected_output = running_output.find { |expected_out| expected_out[:id] == output.id }
|
134
134
|
expect(output.as_json.symbolize_keys).to include expected_output
|
135
135
|
end
|
136
136
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'shared_specs/engine_adapter_specs'
|
3
4
|
|
4
5
|
describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
5
|
-
around
|
6
|
+
around do |example|
|
6
7
|
ActiveEncode::Base.engine_adapter = :ffmpeg
|
7
8
|
|
8
9
|
Dir.mktmpdir do |dir|
|
@@ -10,7 +11,7 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
10
11
|
example.run
|
11
12
|
Dir.foreach(dir) do |e|
|
12
13
|
next if e == "." || e == ".."
|
13
|
-
FileUtils.rm_rf(File.join(dir,e))
|
14
|
+
FileUtils.rm_rf(File.join(dir, e))
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
@@ -18,9 +19,9 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
18
19
|
end
|
19
20
|
|
20
21
|
let!(:work_dir) { stub_const "ActiveEncode::EngineAdapters::FfmpegAdapter::WORK_DIR", @dir }
|
21
|
-
let(:file) { "file
|
22
|
+
let(:file) { "file://" + Rails.root.join('..', 'spec', 'fixtures', 'fireworks.mp4').to_s }
|
22
23
|
let(:created_job) do
|
23
|
-
ActiveEncode::Base.create(file,
|
24
|
+
ActiveEncode::Base.create(file, outputs: [{ label: "low", ffmpeg_opt: "-s 640x480", extension: "mp4" }, { label: "high", ffmpeg_opt: "-s 1280x720", extension: "mp4" }])
|
24
25
|
end
|
25
26
|
let(:running_job) do
|
26
27
|
allow(Process).to receive(:getpgid).and_return 8888
|
@@ -35,24 +36,27 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
35
36
|
end
|
36
37
|
let(:completed_job) { find_encode "completed-id" }
|
37
38
|
let(:failed_job) { find_encode 'failed-id' }
|
38
|
-
let(:completed_tech_metadata)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
let(:completed_tech_metadata) do
|
40
|
+
{
|
41
|
+
audio_bitrate: 171_030,
|
42
|
+
audio_codec: 'mp4a-40-2',
|
43
|
+
duration: 6315,
|
44
|
+
file_size: 199_160,
|
45
|
+
frame_rate: 23.719,
|
46
|
+
height: 110.0,
|
47
|
+
id: "99999",
|
48
|
+
url: "/home/pdinh/Downloads/videoshort.mp4",
|
49
|
+
video_bitrate: 74_477,
|
50
|
+
video_codec: 'avc1',
|
51
|
+
width: 200.0
|
52
|
+
}
|
53
|
+
end
|
50
54
|
let(:completed_output) { [{ id: "99999" }] }
|
51
|
-
let(:failed_tech_metadata) { {
|
55
|
+
let(:failed_tech_metadata) { {} }
|
52
56
|
|
53
57
|
it_behaves_like "an ActiveEncode::EngineAdapter"
|
54
58
|
|
55
|
-
def find_encode
|
59
|
+
def find_encode(id)
|
56
60
|
# Precreate ffmpeg output directory and files
|
57
61
|
FileUtils.copy_entry "spec/fixtures/ffmpeg/#{id}", "#{work_dir}/#{id}"
|
58
62
|
|
@@ -61,7 +65,7 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
61
65
|
FileUtils.touch "#{work_dir}/#{id}/progress"
|
62
66
|
FileUtils.touch Dir.glob("#{work_dir}/#{id}/*.mp4")
|
63
67
|
|
64
|
-
#
|
68
|
+
# Stub out system calls
|
65
69
|
allow_any_instance_of(ActiveEncode::EngineAdapters::FfmpegAdapter).to receive(:`).and_return(1234)
|
66
70
|
|
67
71
|
ActiveEncode::Base.find(id)
|
@@ -86,7 +90,7 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
86
90
|
|
87
91
|
context "input file doesn't exist" do
|
88
92
|
let(:missing_file) { "file:///a_bogus_file.mp4" }
|
89
|
-
let(:missing_job) { ActiveEncode::Base.create(missing_file,
|
93
|
+
let(:missing_job) { ActiveEncode::Base.create(missing_file, outputs: [{ label: "low", ffmpeg_opt: "-s 640x480", extension: 'mp4' }]) }
|
90
94
|
|
91
95
|
it "returns the encode with correct error" do
|
92
96
|
expect(missing_job.errors).to include("#{missing_file} does not exist or is not accessible")
|
@@ -95,8 +99,8 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
95
99
|
end
|
96
100
|
|
97
101
|
context "input file is not media" do
|
98
|
-
let(:nonmedia_file) { "file
|
99
|
-
let(:nonmedia_job) { ActiveEncode::Base.create(nonmedia_file,
|
102
|
+
let(:nonmedia_file) { "file://" + Rails.root.join('Gemfile').to_s }
|
103
|
+
let(:nonmedia_job) { ActiveEncode::Base.create(nonmedia_file, outputs: [{ label: "low", ffmpeg_opt: "-s 640x480", extension: 'mp4' }]) }
|
100
104
|
|
101
105
|
it "returns the encode with correct error" do
|
102
106
|
expect(nonmedia_job.errors).to include("Error inspecting input: #{nonmedia_file}")
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'rubyhorn'
|
3
4
|
require 'shared_specs/engine_adapter_specs'
|
@@ -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
|
@@ -92,8 +93,8 @@ describe ActiveEncode::EngineAdapters::MatterhornAdapter do
|
|
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
|
its(:id) { is_expected.to eq 'cancelled-id' }
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'zencoder'
|
3
4
|
require 'json'
|
@@ -24,11 +25,11 @@ 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
|
its(:id) { is_expected.not_to be_empty }
|
34
35
|
it { is_expected.to be_running }
|
@@ -61,8 +62,8 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
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
|
@@ -94,12 +95,12 @@ 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
|
its(:id) { is_expected.to eq '166019107' }
|
105
106
|
it { is_expected.to be_running }
|
@@ -120,7 +121,7 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
120
121
|
its(:width) { is_expected.to eq 320 }
|
121
122
|
its(:height) { is_expected.to eq 240 }
|
122
123
|
its(:frame_rate) { is_expected.to eq 29.97 }
|
123
|
-
its(:duration) { is_expected.to eq
|
124
|
+
its(:duration) { is_expected.to eq 57_992 }
|
124
125
|
its(:file_size) { is_expected.to be_blank }
|
125
126
|
its(:checksum) { is_expected.to be_blank }
|
126
127
|
its(:audio_codec) { is_expected.to eq "aac" }
|
@@ -133,8 +134,8 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
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
|
@@ -160,10 +161,10 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
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
|
its(:id) { is_expected.to eq '165866551' }
|
169
170
|
it { is_expected.to be_cancelled }
|
@@ -196,12 +197,12 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
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
|
its(:id) { is_expected.to eq '165839139' }
|
207
208
|
it { is_expected.to be_completed }
|
@@ -221,7 +222,7 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
221
222
|
its(:width) { is_expected.to eq 320 }
|
222
223
|
its(:height) { is_expected.to eq 240 }
|
223
224
|
its(:frame_rate) { is_expected.to eq 29.97 }
|
224
|
-
its(:duration) { is_expected.to eq
|
225
|
+
its(:duration) { is_expected.to eq 57_992 }
|
225
226
|
its(:file_size) { is_expected.to be_blank }
|
226
227
|
its(:checksum) { is_expected.to be_blank }
|
227
228
|
its(:audio_codec) { is_expected.to eq "aac" }
|
@@ -234,8 +235,8 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
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
|
@@ -261,12 +262,12 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
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
|
its(:id) { is_expected.to eq '166079902' }
|
272
273
|
it { is_expected.to be_failed }
|
@@ -307,12 +308,12 @@ 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
|
its(:id) { is_expected.to eq '165866551' }
|
318
319
|
it { is_expected.to be_cancelled }
|
@@ -324,12 +325,12 @@ 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
|
its(:id) { is_expected.to eq '166019107' }
|
335
336
|
it { is_expected.to be_running }
|
@@ -349,7 +350,7 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
349
350
|
its(:width) { is_expected.to eq 320 }
|
350
351
|
its(:height) { is_expected.to eq 240 }
|
351
352
|
its(:frame_rate) { is_expected.to eq 29.97 }
|
352
|
-
its(:duration) { is_expected.to eq
|
353
|
+
its(:duration) { is_expected.to eq 57_992 }
|
353
354
|
its(:file_size) { is_expected.to be_blank }
|
354
355
|
its(:checksum) { is_expected.to be_blank }
|
355
356
|
its(:audio_codec) { is_expected.to eq "aac" }
|
@@ -362,8 +363,8 @@ describe ActiveEncode::EngineAdapters::ZencoderAdapter do
|
|
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
|
data/spec/rails_helper.rb
CHANGED