hydra_hls 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5685ed42b13748b8b4f24ae299ef507c1c2301e4
4
- data.tar.gz: 2712d618e496a8257d591b9d526d3f869e4fb384
3
+ metadata.gz: c32e4c406781d813aaee77d4af330e021b4b526f
4
+ data.tar.gz: c39f8ec36f2967a31d468944575a956051c3156c
5
5
  SHA512:
6
- metadata.gz: 86375913f9e4bfb1359ebee52d177bc46915626ed87041694ad146dce010b69ab2fc4b48f50c857f2f41b5ae8d034a909fb181655cf307c5bcb5acfca66b311d
7
- data.tar.gz: 8554200a884034ecbf7e28abbd68f6ddae3ee78dc3f0f1c5ea707e7739ca580460293bd3e4804eac24c8422f6e813b94fcbe0ead346fde1c63d04df2b483911c
6
+ metadata.gz: 24ec6986e2a6f3b20e58c8391d4998606b860f4ab1712e0dc2c500589e22ce4dd5276ad94ea0cbfc5b86eb114df0a0ad0c7b35e418c9b4b21d71f46dc084d6b4
7
+ data.tar.gz: c41ccd0fa7f7259da38e92ce41e8773a2f641cdb0f1abee7fca41ec37702f1f2e8535fbd3eb321258123936ff76fff51424a6ab142c9557c4b603736b2115c3d
@@ -1,3 +1,6 @@
1
+ require "hydra_hls/derivatives/video_derivatives"
2
+ require "hydra_hls/derivatives/audio_derivatives"
3
+
1
4
  module HydraHls
2
5
  module FileSetBehavior
3
6
  extend ActiveSupport::Concern
@@ -35,6 +38,7 @@ module HydraHls
35
38
  playlist << "RESOLUTION=#{options["resolution"]}\n"
36
39
  playlist << File.join(root_url,variant_url(format)) + "\n"
37
40
  }
41
+ playlist
38
42
  end
39
43
 
40
44
  def hls_segment_playlist root_url, format
@@ -78,7 +82,7 @@ module HydraHls
78
82
  { label: 'ogg', format: 'ogg', url: derivative_url('ogg') },
79
83
  { label: 'hls_hd', format: 'hls_hd',path: hls_dir},
80
84
  { label: 'hls', format: 'hls', path: hls_dir}]
81
- HydraHls::Derivatives::AudioDerivatives.create(filename,outputs)
85
+ HydraHls::Derivatives::AudioDerivatives.create(filename,{:outputs => outputs})
82
86
  end
83
87
 
84
88
  def create_video_derivates filename, hls_dir
@@ -88,17 +92,21 @@ module HydraHls
88
92
  { label: 'hls_high', format: "hls_high", path: hls_dir},
89
93
  { label: 'hls_med', format: "hls_med", path: hls_dir},
90
94
  { label: 'hls_low', format: "hls_low", path: hls_dir}]
91
- HydraHls::Derivatives::VideoDerivatives.create(filename,outputs)
95
+ HydraHls::Derivatives::VideoDerivatives.create(filename,{:outputs => outputs})
92
96
  end
93
97
 
94
98
  def token line
95
- @token ||= Digest::SHA256.hexdigest("/" + File.join(segment_url_base,timestamp.to_s,line).strip[0...-9] + hls_config['token_secret'])
99
+ @token ||= Digest::SHA256.hexdigest("/" + File.join(segment_url_base,timestamp.to_s,line).strip[0...-9] + token_secret)
96
100
  end
97
101
 
98
102
  def timestamp
99
103
  @timestamp ||= Time.now.to_i + 7200
100
104
  end
101
105
 
106
+ def token_secret
107
+ @token_secret ||= ENV['hls_token_secret']
108
+ end
109
+
102
110
  def hls_config
103
111
  @hls_config ||= YAML.load_file(Rails.root.join('config','hls.yml'))
104
112
  end
data/config/hls.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  ---
2
- token_secret: <%= ENV["hls_token_secret"] %>
3
2
  video:
4
3
  hls_high:
5
4
  bitrate: 6500000
@@ -4,13 +4,11 @@ video:
4
4
  bitrate: 6500000
5
5
  maxrate: 6800000
6
6
  vf: "scale=1280:-2"
7
- codec_code: "???"
8
7
  resolution: "1280x720"
9
8
  hls_med:
10
9
  bitrate: 3500000
11
10
  maxrate: 3600000
12
11
  vf: "scale=960:-2"
13
- codec_code: "???"
14
12
  resolution: "960x540"
15
13
  hls_low:
16
14
  r: 15
@@ -21,7 +19,7 @@ video:
21
19
  g: 45
22
20
  segment_list_type: m3u8
23
21
  vf: "scale=480:-2"
24
- codec_code: "???"
22
+ codec_code: "mp4a.40.2,avc1.42001e"
25
23
  resolution: "480x360"
26
24
  default:
27
25
  r: 29.97
@@ -30,6 +28,7 @@ video:
30
28
  acodec: aac
31
29
  profile_v: main
32
30
  level: 3.1
31
+ codec_code: "mp4a.40.2,avc1.4d001f"
33
32
  segment_time: 9
34
33
  g: 90
35
34
  vf: "scale=960:-2"
@@ -46,6 +45,5 @@ audio:
46
45
  segment_time: 9
47
46
  segment_format: mpeg_ts
48
47
  segment_list_type: m3u8
49
- codec_code: ???
48
+ codec_code: "mp4a.40.2"
50
49
  resolution: 300x50
51
- token_secret: <%= ENV["hls_token_secret"] %>
@@ -1,4 +1,4 @@
1
- class FileSetsController < CurationConcerns::FilesSetsController
1
+ class FileSetsController < CurationConcerns::FileSetsController
2
2
  include HydraHls::FileSetsControllerBehavior
3
3
  end
4
4
 
@@ -1,7 +1,8 @@
1
+ require "hydra_hls/derivatives/processors/audio"
1
2
  module HydraHls::Derivatives
2
3
  class AudioDerivatives < Hydra::Derivatives::AudioDerivatives
3
4
  def self.processor_class
4
- Processors::AudioProcessor
5
+ HydraHls::Derivatives::Processors::Audio
5
6
  end
6
7
  end
7
8
  end
@@ -1,30 +1,36 @@
1
- module HydraHls::Derivatives::Processors
2
- class Audio < Hydra::Derivatives::Processors::Audio
3
- include Media
1
+ require "hydra_hls/derivatives/processors"
2
+ require "hydra_hls/derivatives/processors/media"
3
+ module HydraHls
4
+ module Derivatives
5
+ module Processors
6
+ class Audio < Hydra::Derivatives::Processors::Audio
7
+ include Media
4
8
 
5
- def options_for(format)
6
- return super unless format.include?("hls")
7
- input_options="-y"
8
- outopts = get_hls_options(format).symbolize_keys
9
- output_options = "-acodec #{outopts[:acodec]} -b:a #{outopts[:bitrate]} -maxrate: #{outopts[:maxrate]} -f segment -segment_time #{outopts[:segment_time]} -flags -global_header -segment_format mpeg_ts -segment_list_type m3u8"
9
+ def options_for(format)
10
+ return super unless format.include?("hls")
11
+ input_options="-y"
12
+ outopts = get_hls_options(format).symbolize_keys
13
+ output_options = "-acodec #{outopts[:acodec]} -b:a #{outopts[:bitrate]} -maxrate: #{outopts[:maxrate]} -f segment -segment_time #{outopts[:segment_time]} -flags -global_header -segment_format mpeg_ts -segment_list_type m3u8"
10
14
 
11
- { Hydra::Derivatives::Processors::Ffmpeg::OUTPUT_OPTIONS => output_options,
12
- Hydra::Derivatives::Processors::Ffmpeg::INPUT_OPTIONS => input_options,
13
- :format => format}
14
- end
15
+ { Hydra::Derivatives::Processors::Ffmpeg::OUTPUT_OPTIONS => output_options,
16
+ Hydra::Derivatives::Processors::Ffmpeg::INPUT_OPTIONS => input_options,
17
+ :format => format}
18
+ end
15
19
 
16
- def codecs(format)
17
- return super unless format.include?("hls")
18
- options = get_hls_options(format)
19
- "-acodec #{options[:acodec]}"
20
- end
20
+ def codecs(format)
21
+ return super unless format.include?("hls")
22
+ options = get_hls_options(format)
23
+ "-acodec #{options[:acodec]}"
24
+ end
21
25
 
22
- private
26
+ private
23
27
 
24
- def get_hls_options(format)
25
- config = YAML.load_file(Rails.root.join('config','hls.yml'))["audio"]
26
- config["default"].merge(config[format])
27
- end
28
+ def get_hls_options(format)
29
+ config = YAML.load_file(Rails.root.join('config','hls.yml'))["audio"]
30
+ config["default"].merge(config[format])
31
+ end
28
32
 
33
+ end
34
+ end
29
35
  end
30
36
  end
@@ -1,24 +1,28 @@
1
- module HydraHls::Derivatives::Processors
2
- module Media
3
-
4
- def encode_file(file_suffix, options)
5
- return super(file_suffix,options) unless file_suffix.include?("hls")
6
- Dir::mktmpdir(['sufia', "_#{file_suffix}"], Hydra::Derivatives.temp_file_base){ |temp_dir|
7
- self.class.encode(source_path, options, temp_dir.to_s, true)
8
- HydraHls::HlsOutputFileService.call(directives, temp_dir)
9
- }
10
- end
1
+ module HydraHls
2
+ module Derivatives
3
+ module Processors
4
+ module Media
5
+
6
+ def encode_hls(input_path, options, output_dir)
7
+ segment_base = File.join(output_dir, options[:format])
8
+ segment_list = segment_base + ".m3u8"
9
+ segment_files = segment_base + "_%05d.ts"
10
+ inopts = options[Hydra::Derivatives::Processors::Ffmpeg::INPUT_OPTIONS] ||= "-y"
11
+ outopts = options[Hydra::Derivatives::Processors::Ffmpeg::OUTPUT_OPTIONS]
12
+ output_files = "-segment_list #{segment_list} #{segment_files}"
13
+ self.class.execute "#{Hydra::Derivatives.ffmpeg_path} #{inopts} -i \"#{input_path}\" #{outopts} #{output_files}"
14
+ end
11
15
 
12
- def self.encode(input_path, options, output_dir, hls=false)
13
- return super(input_path,options,output_dir) unless hls
14
- segment_base = File.join(output_dir, options[:format])
15
- segment_list = segment_base + ".m3u8"
16
- segment_files = segment_base + "_%05d.ts"
17
- inopts = options[INPUT_OPTIONS] ||= "-y"
18
- outopts = options[OUTPUT_OPTIONS]
19
- output_files = "-segment_list #{segment_list} #{segment_files}"
20
- execute "#{Hydra::Derivatives.ffmpeg_path} #{inopts} -i \"#{input_path}\" #{outopts} #{output_files}"
21
- end
22
16
 
23
- end
17
+ def encode_file(file_suffix, options)
18
+ return super(file_suffix,options) unless file_suffix.include?("hls")
19
+ Dir::mktmpdir(['sufia', "_#{file_suffix}"], Hydra::Derivatives.temp_file_base){ |temp_dir|
20
+ encode_hls(source_path, options, temp_dir.to_s)
21
+ HydraHls::HlsOutputFileService.call(directives, temp_dir)
22
+ }
23
+ end
24
+
25
+ end
26
+ end
27
+ end
24
28
  end
@@ -1,30 +1,37 @@
1
- module HydraHls::Derivatives::Processors
2
- class Video < Hydra::Derivatives::Processors::Video::Processor
3
- include Media
1
+ require "hydra_hls/derivatives/processors"
2
+ require "hydra_hls/derivatives/processors/media"
3
+ module HydraHls
4
+ module Derivatives
5
+ module Processors
6
+ class Video < Hydra::Derivatives::Processors::Video::Processor
7
+ include Media
4
8
 
5
- def options_for(format)
6
- return super unless format.include?("hls")
7
- input_option_string="-y"
8
- outopts = get_hls_options(format).symbolize_keys
9
- output_option_string = "-pix_fmt #{outopts[:pix_fmt]} -vcodec #{outopts[:vcodec]} -acodec #{outopts[:acodec]} -r #{outopts[:r]} -profile:v #{outopts[:profile_v]} -level #{outopts[:level]} -b:v #{outopts[:bitrate]} -maxrate: #{outopts[:maxrate]} -f segment -segment_time #{outopts[:segment_time]} -g #{outopts[:g]} -map 0 -flags -global_header -segment_format mpeg_ts -segment_list_type m3u8 -vf #{outopts[:vf]} "
10
-
11
- { Hydra::Derivatives::Processors::Ffmpeg::OUTPUT_OPTIONS => output_option_string,
12
- Hydra::Derivatives::Processors::Ffmpeg::INPUT_OPTIONS => input_option_string,
13
- :format => format}
14
- end
9
+ def options_for(format)
10
+ return super unless format.include?("hls")
11
+ input_option_string="-y"
12
+ outopts = get_hls_options(format).symbolize_keys
13
+ output_option_string = "-pix_fmt #{outopts[:pix_fmt]} -vcodec #{outopts[:vcodec]} -acodec #{outopts[:acodec]} -r #{outopts[:r]} -profile:v #{outopts[:profile_v]} -level #{outopts[:level]} -b:v #{outopts[:bitrate]} -maxrate: #{outopts[:maxrate]} -f segment -segment_time #{outopts[:segment_time]} -g #{outopts[:g]} -map 0 -flags -global_header -segment_format mpeg_ts -segment_list_type m3u8 -vf #{outopts[:vf]} "
14
+
15
+ { Hydra::Derivatives::Processors::Ffmpeg::OUTPUT_OPTIONS => output_option_string,
16
+ Hydra::Derivatives::Processors::Ffmpeg::INPUT_OPTIONS => input_option_string,
17
+ :format => format}
18
+ end
15
19
 
16
- def codecs(format)
17
- return super unless format.include?("hls")
18
- options = get_hls_options(format)
19
- "-vcodec #{options[:vcodec]} -acodec #{options[:acodec]}"
20
- end
20
+ def codecs(format)
21
+ return super unless format.include?("hls")
22
+ options = get_hls_options(format)
23
+ "-vcodec #{options[:vcodec]} -acodec #{options[:acodec]}"
24
+ end
25
+
26
+ private
21
27
 
22
- private
28
+ def get_hls_options(format)
29
+ config = YAML.load_file(Rails.root.join('config','hls.yml'))["video"]
30
+ config["default"].merge(config[format])
31
+ end
23
32
 
24
- def get_hls_options(format)
25
- config = YAML.load_file(Rails.root.join('config','hls.yml'))["video"]
26
- config["default"].merge(config[format])
33
+
34
+ end
27
35
  end
28
-
29
36
  end
30
37
  end
@@ -1,5 +1,7 @@
1
- module HydraHls::Derivatives
2
- module Processors
3
- extend ActiveSupport::Autoload
1
+ module HydraHls
2
+ module Derivatives
3
+ module Processors
4
+ extend ActiveSupport::Autoload
5
+ end
4
6
  end
5
7
  end
@@ -1,7 +1,10 @@
1
- module HydraHls::Derivatives
2
- class UcscVideoDerivatives < Hydra::Derivatives::VideoDerivatives
3
- def self.processor_class
4
- Processors::VideoProcessor
1
+ require "hydra_hls/derivatives/processors/video"
2
+ module HydraHls
3
+ module Derivatives
4
+ class VideoDerivatives < Hydra::Derivatives::VideoDerivatives
5
+ def self.processor_class
6
+ HydraHls::Derivatives::Processors::Video
7
+ end
5
8
  end
6
9
  end
7
10
  end
@@ -1,3 +1,5 @@
1
+ require "hydra_hls/derivatives/audio_derivatives"
2
+ require "hydra_hls/derivatives/video_derivatives"
1
3
  module HydraHls
2
4
  module Derivatives
3
5
  end
@@ -1,5 +1,6 @@
1
1
  module HydraHls
2
2
  class Engine < ::Rails::Engine
3
+ config.autoload_paths << File.expand_path("derivatives", __FILE__)
3
4
  engine_name 'hydra_hls'
4
5
  end
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module HydraHls
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra_hls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ned Henry, UCSC Library Digital Initiatives
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails