active_encode 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +72 -0
  3. data/.rubocop.yml +8 -70
  4. data/.rubocop_todo.yml +64 -0
  5. data/Gemfile +3 -3
  6. data/active_encode.gemspec +4 -1
  7. data/app/controllers/active_encode/encode_record_controller.rb +1 -0
  8. data/app/jobs/active_encode/polling_job.rb +1 -1
  9. data/app/models/active_encode/encode_record.rb +1 -0
  10. data/db/migrate/20180822021048_create_active_encode_encode_records.rb +1 -0
  11. data/db/migrate/20190702153755_add_create_options_to_active_encode_encode_records.rb +6 -0
  12. data/db/migrate/20190712174821_add_progress_to_active_encode_encode_records.rb +6 -0
  13. data/lib/active_encode.rb +1 -0
  14. data/lib/active_encode/base.rb +1 -0
  15. data/lib/active_encode/callbacks.rb +1 -0
  16. data/lib/active_encode/core.rb +4 -3
  17. data/lib/active_encode/engine.rb +1 -0
  18. data/lib/active_encode/engine_adapter.rb +1 -0
  19. data/lib/active_encode/engine_adapters.rb +2 -1
  20. data/lib/active_encode/engine_adapters/elastic_transcoder_adapter.rb +25 -24
  21. data/lib/active_encode/engine_adapters/ffmpeg_adapter.rb +43 -58
  22. data/lib/active_encode/engine_adapters/matterhorn_adapter.rb +5 -4
  23. data/lib/active_encode/engine_adapters/test_adapter.rb +5 -4
  24. data/lib/active_encode/engine_adapters/zencoder_adapter.rb +3 -2
  25. data/lib/active_encode/global_id.rb +2 -1
  26. data/lib/active_encode/input.rb +3 -2
  27. data/lib/active_encode/output.rb +3 -2
  28. data/lib/active_encode/persistence.rb +7 -3
  29. data/lib/active_encode/polling.rb +2 -1
  30. data/lib/active_encode/status.rb +1 -0
  31. data/lib/active_encode/technical_metadata.rb +3 -2
  32. data/lib/active_encode/version.rb +2 -1
  33. data/lib/file_locator.rb +7 -8
  34. data/spec/controllers/encode_record_controller_spec.rb +2 -1
  35. data/spec/integration/elastic_transcoder_adapter_spec.rb +26 -26
  36. data/spec/integration/ffmpeg_adapter_spec.rb +26 -22
  37. data/spec/integration/matterhorn_adapter_spec.rb +6 -5
  38. data/spec/integration/zencoder_adapter_spec.rb +15 -14
  39. data/spec/rails_helper.rb +1 -0
  40. data/spec/routing/encode_record_controller_routing_spec.rb +1 -0
  41. data/spec/shared_specs/engine_adapter_specs.rb +1 -1
  42. data/spec/spec_helper.rb +2 -1
  43. data/spec/test_app_templates/lib/generators/test_app_generator.rb +13 -12
  44. data/spec/units/callbacks_spec.rb +3 -2
  45. data/spec/units/core_spec.rb +9 -8
  46. data/spec/units/engine_adapter_spec.rb +1 -0
  47. data/spec/units/file_locator_spec.rb +19 -18
  48. data/spec/units/global_id_spec.rb +4 -3
  49. data/spec/units/input_spec.rb +8 -5
  50. data/spec/units/output_spec.rb +8 -5
  51. data/spec/units/persistence_spec.rb +8 -4
  52. data/spec/units/polling_job_spec.rb +7 -6
  53. data/spec/units/polling_spec.rb +1 -0
  54. data/spec/units/status_spec.rb +3 -3
  55. metadata +37 -7
  56. data/.travis.yml +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4a97d45ac966ff1988311fd6787fde4bc9b40850fb83ddd78aaa79ef495a885
4
- data.tar.gz: f66be6fc89de6e14cb192cc55f6d467a211598804511f8aca981e3d441dd9493
3
+ metadata.gz: 22be45555a3ea9208b56552c17e86a0052865e753cd2cd03fae9a876ebee6964
4
+ data.tar.gz: 55ba9a105b56e2d660b8bbe237cee26dc10caea24c87dd0b7e81a46b2ad28979
5
5
  SHA512:
6
- metadata.gz: 360d90909956f64d5e499e1260128a85ac498891cdc4eb448e9ce53f5e4cc02372bec4df79143129202963fab95d8e4fc6c79f83335346d82b2fa2a20bf4d4df
7
- data.tar.gz: 76bf91cce817790e2b9775e83df44208812f024e353524cccbfc470525b083c2b172c6576af8f8711896b227e5fab438feb97c3da4b9849c1b378451ebfb62a8
6
+ metadata.gz: b3ced87039d84e596fc2f011f70b586ef46d2501af00d94e64e91a2241df93c9e93b153814125454eb8af96ae63a2289188067fa4193fe01ee6568d5b9471113
7
+ data.tar.gz: 5dc21ccd48592fe2460599404f17c886f242f77a57cd3dbc9a8064176da44f9f1566a9cbf2c529491f037f25da252e0dd3fe40e345b15d9310b7c4464add310a
@@ -0,0 +1,72 @@
1
+ version: 2.1
2
+ orbs:
3
+ samvera: samvera/circleci-orb@0
4
+ jobs:
5
+ bundle_and_test:
6
+ parameters:
7
+ ruby_version:
8
+ type: string
9
+ default: 2.6.3
10
+ rails_version:
11
+ type: string
12
+ default: 5.2.3
13
+ bundler_version:
14
+ type: string
15
+ default: 2.0.1
16
+ executor:
17
+ name: 'samvera/ruby'
18
+ ruby_version: << parameters.ruby_version >>
19
+ environment:
20
+ ENGINE_CART_RAILS_OPTIONS: --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-coffee --skip-puma --skip-test
21
+ RAILS_VERSION: << parameters.rails_version >>
22
+ working_directory: ~/project
23
+ steps:
24
+ - run: sudo apt-get install libmms0
25
+ - run: sudo wget -P /tmp/ https://mediaarea.net/download/binary/libzen0/0.4.37/libzen0v5_0.4.37-1_amd64.Debian_9.0.deb
26
+ - run: sudo wget -P /tmp/ https://mediaarea.net/download/binary/libmediainfo0/19.04/libmediainfo0v5_19.04-1_amd64.Debian_9.0.deb
27
+ - run: sudo wget -P /tmp/ https://mediaarea.net/download/binary/mediainfo/19.04/mediainfo_19.04-1_amd64.Debian_9.0.deb
28
+ - run: sudo dpkg -i /tmp/libzen0v5_0.4.37-1_amd64.Debian_9.0.deb /tmp/libmediainfo0v5_19.04-1_amd64.Debian_9.0.deb /tmp/mediainfo_19.04-1_amd64.Debian_9.0.deb
29
+
30
+ - samvera/cached_checkout
31
+
32
+ - samvera/bundle_for_gem:
33
+ ruby_version: << parameters.ruby_version >>
34
+ bundler_version: << parameters.bundler_version >>
35
+ project: active_encode
36
+
37
+ - samvera/engine_cart_generate:
38
+ cache_key: v2-internal-test-app-{{ checksum "active_encode.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-<< parameters.rails_version >>-<< parameters.ruby_version >>
39
+
40
+ - samvera/bundle_for_gem:
41
+ ruby_version: << parameters.ruby_version >>
42
+ bundler_version: << parameters.bundler_version >>
43
+ project: active_encode
44
+
45
+ - samvera/rubocop
46
+
47
+ - samvera/parallel_rspec
48
+
49
+ workflows:
50
+ ci:
51
+ jobs:
52
+ - bundle_and_test:
53
+ name: "ruby2-6_rails5-2"
54
+ ruby_version: "2.6.3"
55
+ - bundle_and_test:
56
+ name: "ruby2-5_rails5-2"
57
+ ruby_version: "2.5.5"
58
+ - bundle_and_test:
59
+ name: "ruby2-4_rails5-2"
60
+ ruby_version: "2.4.6"
61
+ - bundle_and_test:
62
+ name: "ruby2-6_rails5-1"
63
+ ruby_version: "2.6.3"
64
+ rails_version: "5.1.7"
65
+ - bundle_and_test:
66
+ name: "ruby2-5_rails5-1"
67
+ ruby_version: "2.5.5"
68
+ rails_version: "5.1.7"
69
+ - bundle_and_test:
70
+ name: "ruby2-4_rails5-1"
71
+ ruby_version: "2.4.6"
72
+ rails_version: "5.1.7"
@@ -1,75 +1,13 @@
1
- require: rubocop-rspec
1
+ inherit_gem:
2
+ bixby: bixby_default.yml
3
+
4
+ inherit_from: .rubocop_todo.yml
5
+
2
6
 
3
7
  AllCops:
8
+ TargetRubyVersion: 2.4
4
9
  DisplayCopNames: true
5
- Include:
6
- - '**/Rakefile'
7
10
  Exclude:
8
- - 'spec/**/*'
9
11
  - 'vendor/**/*'
10
-
11
- Rails:
12
- Enabled: True
13
-
14
- Metrics/LineLength:
15
- Enabled: false
16
-
17
- Metrics/AbcSize:
18
- Enabled: false
19
-
20
- Metrics/MethodLength:
21
- Exclude:
22
- - 'lib/active_encode/engine_adapters/*'
23
-
24
- Metrics/ClassLength:
25
- Exclude:
26
- - 'lib/active_encode/engine_adapters/*'
27
-
28
- Metrics/CyclomaticComplexity:
29
- Exclude:
30
- - 'lib/active_encode/engine_adapters/*'
31
-
32
- Style/IndentationConsistency:
33
- EnforcedStyle: rails
34
-
35
- Style/CollectionMethods:
36
- PreferredMethods:
37
- collect: 'map'
38
- collect!: 'map!'
39
- inject: 'reduce'
40
- detect: 'find'
41
- find_all: 'select'
42
-
43
- Style/FileName: # https://github.com/bbatsov/rubocop/issues/2973
44
- Exclude:
45
- - 'Gemfile'
46
-
47
- Style/WordArray:
48
- Enabled: false
49
-
50
- Style/RegexpLiteral:
51
- Enabled: false
52
-
53
- Style/StringLiterals:
54
- Enabled: false
55
-
56
- Style/ClassAndModuleChildren:
57
- Enabled: false
58
-
59
- Style/Documentation:
60
- Enabled: false
61
-
62
- RSpec/ExampleWording:
63
- CustomTransform:
64
- be: is
65
- have: has
66
- not: does not
67
- NOT: does NOT
68
- IgnoredWords:
69
- - only
70
-
71
- RSpec/FilePath:
72
- Enabled: false
73
-
74
- RSpec/InstanceVariable:
75
- Enabled: false
12
+ Include:
13
+ - '**/Rakefile'
@@ -0,0 +1,64 @@
1
+ Bundler/DuplicatedGem:
2
+ Enabled: false
3
+
4
+ Metrics/AbcSize:
5
+ Exclude:
6
+ - 'lib/active_encode/engine_adapters/*'
7
+
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - 'spec/**/*'
11
+
12
+ Metrics/BlockNesting:
13
+ Exclude:
14
+ - 'lib/file_locator.rb'
15
+
16
+ Metrics/ClassLength:
17
+ Exclude:
18
+ - 'lib/active_encode/engine_adapters/*'
19
+
20
+ Metrics/CyclomaticComplexity:
21
+ Exclude:
22
+ - 'lib/active_encode/engine_adapters/ffmpeg_adapter.rb'
23
+ - 'lib/active_encode/engine_adapters/zencoder_adapter.rb'
24
+
25
+ Metrics/LineLength:
26
+ Exclude:
27
+ - 'lib/active_encode/engine_adapters/matterhorn_adapter.rb'
28
+ - 'spec/**/*'
29
+
30
+ Metrics/MethodLength:
31
+ Exclude:
32
+ - 'lib/active_encode/engine_adapters/*'
33
+ - 'lib/file_locator.rb'
34
+
35
+ Metrics/PerceivedComplexity:
36
+ Exclude:
37
+ - 'lib/active_encode/engine_adapters/ffmpeg_adapter.rb'
38
+ - 'lib/file_locator.rb'
39
+
40
+ RSpec/AnyInstance:
41
+ Exclude:
42
+ - 'spec/integration/ffmpeg_adapter_spec.rb'
43
+
44
+ RSpec/ExampleLength:
45
+ Enabled: false
46
+
47
+ RSpec/InstanceVariable:
48
+ Exclude:
49
+ - 'spec/integration/ffmpeg_adapter_spec.rb'
50
+
51
+ RSpec/MessageSpies:
52
+ Exclude:
53
+ - 'spec/integration/matterhorn_adapter_spec.rb'
54
+ - 'spec/integration/ffmpeg_adapter_spec.rb'
55
+
56
+ RSpec/NamedSubject:
57
+ Enabled: false
58
+
59
+ RSpec/VerifiedDoubles:
60
+ Enabled: false
61
+
62
+ Style/GuardClause:
63
+ Exclude:
64
+ - 'lib/file_locator.rb'
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in hydra-transcoder.gemspec
4
5
  gemspec
5
6
 
7
+ gem 'addressable'
6
8
  gem 'aws-sdk'
7
9
  gem 'byebug'
8
- gem 'rubocop', require: false
9
- gem 'rubocop-rspec', require: false
10
10
  gem 'rubyhorn', git: "https://github.com/avalonmediasystem/rubyhorn.git"
11
11
  gem 'shingoncoder'
12
12
  gem 'zencoder'
@@ -37,9 +37,9 @@ else
37
37
 
38
38
  case ENV['RAILS_VERSION']
39
39
  when /^4.2/
40
+ gem 'coffee-rails', '~> 4.1.0'
40
41
  gem 'responders', '~> 2.0'
41
42
  gem 'sass-rails', '>= 5.0'
42
- gem 'coffee-rails', '~> 4.1.0'
43
43
  when /^4.[01]/
44
44
  gem 'sass-rails', '< 5.0'
45
45
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  lib = File.expand_path('../lib', __FILE__)
4
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -10,7 +11,7 @@ Gem::Specification.new do |spec|
10
11
  spec.authors = ["Michael Klein, Chris Colvard, Phuong Dinh"]
11
12
  spec.email = ["mbklein@gmail.com, chris.colvard@gmail.com, phuongdh@gmail.com"]
12
13
  spec.summary = 'Declare encode job classes that can be run by a variety of encoding services'
13
- spec.description = 'This gem serves as the basis for the interface between a Ruby (Rails) application and a provider of transcoding services such as Opencast Matterhorn, Zencoder, and Amazon Elastic Transcoder.'
14
+ spec.description = 'This gem provides an interface to transcoding services such as Ffmpeg, Amazon Elastic Transcoder, or Zencoder.'
14
15
  spec.homepage = "https://github.com/samvera-labs/active_encode"
15
16
  spec.license = "Apache-2.0"
16
17
 
@@ -22,6 +23,7 @@ Gem::Specification.new do |spec|
22
23
  spec.add_dependency "rails"
23
24
 
24
25
  spec.add_development_dependency "aws-sdk"
26
+ spec.add_development_dependency "bixby", '~> 1.0.0'
25
27
  spec.add_development_dependency "bundler"
26
28
  spec.add_development_dependency "coveralls"
27
29
  spec.add_development_dependency "database_cleaner"
@@ -29,5 +31,6 @@ Gem::Specification.new do |spec|
29
31
  spec.add_development_dependency "rake"
30
32
  spec.add_development_dependency "rspec"
31
33
  spec.add_development_dependency "rspec-its"
34
+ spec.add_development_dependency 'rspec_junit_formatter'
32
35
  spec.add_development_dependency "rspec-rails"
33
36
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveEncode
2
3
  class EncodeRecordController < ActionController::Base
3
4
  rescue_from ActiveRecord::RecordNotFound do |e|
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveEncode
2
3
  class PollingJob < ActiveJob::Base
3
-
4
4
  def perform(encode)
5
5
  encode.run_callbacks(:status_update) { encode }
6
6
  case encode.state
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveEncode
2
3
  class EncodeRecord < ActiveRecord::Base
3
4
  # sql id, globalid, state, adapter, input filename/job title, timestamps
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class CreateActiveEncodeEncodeRecords < ActiveRecord::Migration[5.0]
2
3
  def change
3
4
  create_table :active_encode_encode_records do |t|
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ class AddCreateOptionsToActiveEncodeEncodeRecords < ActiveRecord::Migration[5.0]
3
+ def change
4
+ add_column :active_encode_encode_records, :create_options, :text
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ class AddProgressToActiveEncodeEncodeRecords < ActiveRecord::Migration[5.1]
3
+ def change
4
+ add_column :active_encode_encode_records, :progress, :float
5
+ end
6
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_encode/version'
2
3
  require 'active_encode/base'
3
4
  require 'active_encode/engine'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_encode/core'
2
3
  require 'active_encode/engine_adapter'
3
4
  require 'active_encode/status'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_model/callbacks'
2
3
 
3
4
  module ActiveEncode
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support'
2
3
  require 'active_encode/callbacks'
3
4
 
@@ -44,19 +45,19 @@ module ActiveEncode
44
45
  end
45
46
 
46
47
  def initialize(input_url, options = nil)
47
- @input = Input.new.tap{ |input| input.url = input_url }
48
+ @input = Input.new.tap { |input| input.url = input_url }
48
49
  @options = self.class.default_options(input_url).merge(Hash(options))
49
50
  end
50
51
 
51
52
  def create!
52
53
  run_callbacks :create do
53
- merge!(self.class.engine_adapter.create(self.input.url, self.options))
54
+ merge!(self.class.engine_adapter.create(input.url, options))
54
55
  end
55
56
  end
56
57
 
57
58
  def cancel!
58
59
  run_callbacks :cancel do
59
- merge!(self.class.engine_adapter.cancel(self.id))
60
+ merge!(self.class.engine_adapter.cancel(id))
60
61
  end
61
62
  end
62
63
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails'
2
3
 
3
4
  module ActiveEncode
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_encode/engine_adapters'
2
3
  require 'active_support/core_ext/class/attribute'
3
4
  require 'active_support/core_ext/string/inflections'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActiveEncode
2
3
  # == Active Encode adapters
3
4
  #
@@ -14,7 +15,7 @@ module ActiveEncode
14
15
  autoload :TestAdapter
15
16
  autoload :FfmpegAdapter
16
17
 
17
- ADAPTER = 'Adapter'.freeze
18
+ ADAPTER = 'Adapter'
18
19
  private_constant :ADAPTER
19
20
 
20
21
  class << self
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'addressable/uri'
2
3
  require 'aws-sdk'
3
4
  require 'file_locator'
@@ -5,11 +6,10 @@ require 'file_locator'
5
6
  module ActiveEncode
6
7
  module EngineAdapters
7
8
  class ElasticTranscoderAdapter
8
-
9
9
  JOB_STATES = {
10
10
  "Submitted" => :running, "Progressing" => :running, "Canceled" => :cancelled,
11
11
  "Error" => :failed, "Complete" => :completed
12
- }
12
+ }.freeze
13
13
 
14
14
  # Require options to include :pipeline_id, :masterfile_bucket and :outputs
15
15
  # Example :outputs value:
@@ -29,7 +29,7 @@ module ActiveEncode
29
29
  build_encode(job)
30
30
  end
31
31
 
32
- def find(id, opts = {})
32
+ def find(id, _opts = {})
33
33
  build_encode(get_job_details(id))
34
34
  end
35
35
 
@@ -58,14 +58,14 @@ module ActiveEncode
58
58
  return nil if job.nil?
59
59
  encode = ActiveEncode::Base.new(convert_input(job), {})
60
60
  encode.id = job.id
61
- encode.state = JOB_STATES[job.status]
62
- encode.current_operations = []
63
- encode.percent_complete = convert_percent_complete(job)
64
- encode.created_at = convert_time(job.timing["submit_time_millis"])
65
- encode.updated_at = convert_time(job.timing["finish_time_millis"]) || convert_time(job.timing["start_time_millis"]) || encode.created_at
61
+ encode.state = JOB_STATES[job.status]
62
+ encode.current_operations = []
63
+ encode.percent_complete = convert_percent_complete(job)
64
+ encode.created_at = convert_time(job.timing["submit_time_millis"])
65
+ encode.updated_at = convert_time(job.timing["finish_time_millis"]) || convert_time(job.timing["start_time_millis"]) || encode.created_at
66
66
 
67
- encode.output = convert_output(job)
68
- encode.errors = job.outputs.select { |o| o.status == "Error" }.collect(&:status_detail).compact
67
+ encode.output = convert_output(job)
68
+ encode.errors = job.outputs.select { |o| o.status == "Error" }.collect(&:status_detail).compact
69
69
 
70
70
  tech_md = convert_tech_metadata(job.input.detected_properties)
71
71
  [:width, :height, :frame_rate, :duration, :file_size].each do |field|
@@ -82,7 +82,7 @@ module ActiveEncode
82
82
 
83
83
  def convert_time(time_millis)
84
84
  return nil if time_millis.nil?
85
- Time.at(time_millis / 1000)
85
+ Time.at(time_millis / 1000).utc
86
86
  end
87
87
 
88
88
  def convert_bitrate(rate)
@@ -124,35 +124,35 @@ module ActiveEncode
124
124
  job.input
125
125
  end
126
126
 
127
- def copy_to_input_bucket input_url, bucket
127
+ def copy_to_input_bucket(input_url, bucket)
128
128
  case Addressable::URI.parse(input_url).scheme
129
- when nil,'file'
129
+ when nil, 'file'
130
130
  upload_to_s3 input_url, bucket
131
131
  when 's3'
132
132
  check_s3_bucket input_url, bucket
133
133
  end
134
134
  end
135
135
 
136
- def check_s3_bucket input_url, source_bucket
136
+ def check_s3_bucket(input_url, source_bucket)
137
137
  # logger.info("Checking `#{input_url}'")
138
138
  s3_object = FileLocator::S3File.new(input_url).object
139
139
  if s3_object.bucket_name == source_bucket
140
140
  # logger.info("Already in bucket `#{source_bucket}'")
141
141
  s3_object.key
142
142
  else
143
- s3_key = File.join(SecureRandom.uuid,s3_object.key)
143
+ s3_key = File.join(SecureRandom.uuid, s3_object.key)
144
144
  # logger.info("Copying to `#{source_bucket}/#{input_url}'")
145
145
  target = Aws::S3::Object.new(bucket_name: source_bucket, key: input_url)
146
- target.copy_from(s3_object, multipart_copy: s3_object.size > 15728640) # 15.megabytes
146
+ target.copy_from(s3_object, multipart_copy: s3_object.size > 15_728_640) # 15.megabytes
147
147
  s3_key
148
148
  end
149
149
  end
150
150
 
151
- def upload_to_s3 input_url, source_bucket
152
- original_input = input_url
151
+ def upload_to_s3(input_url, source_bucket)
152
+ # original_input = input_url
153
153
  bucket = Aws::S3::Resource.new(client: s3client).bucket(source_bucket)
154
154
  filename = FileLocator.new(input_url).location
155
- s3_key = File.join(SecureRandom.uuid,File.basename(filename))
155
+ s3_key = File.join(SecureRandom.uuid, File.basename(filename))
156
156
  # logger.info("Copying `#{original_input}' to `#{source_bucket}/#{input_url}'")
157
157
  obj = bucket.object(s3_key)
158
158
  obj.upload_file filename
@@ -169,12 +169,13 @@ module ActiveEncode
169
169
  job.outputs.collect do |joutput|
170
170
  preset = read_preset(joutput.preset_id)
171
171
  extension = preset.container == 'ts' ? '.m3u8' : ''
172
- tech_md = convert_tech_metadata(joutput, preset).merge({
172
+ additional_metadata = {
173
173
  managed: false,
174
174
  id: joutput.id,
175
175
  label: joutput.key.split("/", 2).first,
176
176
  url: "s3://#{pipeline.output_bucket}/#{job.output_key_prefix}#{joutput.key}#{extension}"
177
- })
177
+ }
178
+ tech_md = convert_tech_metadata(joutput, preset).merge(additional_metadata)
178
179
 
179
180
  output = ActiveEncode::Output.new
180
181
  output.state = convert_state(joutput)
@@ -194,7 +195,7 @@ module ActiveEncode
194
195
  job.outputs.select { |o| o.status == "Error" }.collect(&:status_detail).compact
195
196
  end
196
197
 
197
- def convert_tech_metadata(props, preset=nil)
198
+ def convert_tech_metadata(props, preset = nil)
198
199
  return {} if props.nil? || props.empty?
199
200
  metadata_fields = {
200
201
  file_size: { key: :file_size, method: :itself },
@@ -216,13 +217,13 @@ module ActiveEncode
216
217
  unless preset.nil?
217
218
  audio = preset.audio
218
219
  video = preset.video
219
- metadata.merge!({
220
+ metadata.merge!(
220
221
  audio_codec: audio&.codec,
221
222
  audio_channels: audio&.channels,
222
223
  audio_bitrate: convert_bitrate(audio&.bit_rate),
223
224
  video_codec: video&.codec,
224
225
  video_bitrate: convert_bitrate(video&.bit_rate)
225
- })
226
+ )
226
227
  end
227
228
 
228
229
  metadata