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 +4 -4
- data/app/models/concerns/hydra_hls/file_set_behavior.rb +11 -3
- data/config/hls.yml +0 -1
- data/lib/generators/hydra_hls/install/templates/config/hls.yml.example +3 -5
- data/lib/generators/hydra_hls/install/templates/controllers/file_sets_controller.rb +1 -1
- data/lib/hydra_hls/derivatives/audio_derivatives.rb +2 -1
- data/lib/hydra_hls/derivatives/processors/audio.rb +28 -22
- data/lib/hydra_hls/derivatives/processors/media.rb +25 -21
- data/lib/hydra_hls/derivatives/processors/video.rb +30 -23
- data/lib/hydra_hls/derivatives/processors.rb +5 -3
- data/lib/hydra_hls/derivatives/video_derivatives.rb +7 -4
- data/lib/hydra_hls/derivatives.rb +2 -0
- data/lib/hydra_hls/engine.rb +1 -0
- data/lib/hydra_hls/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c32e4c406781d813aaee77d4af330e021b4b526f
|
4
|
+
data.tar.gz: c39f8ec36f2967a31d468944575a956051c3156c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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] +
|
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
@@ -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,30 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
26
|
+
private
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
config["default"].merge(config[format])
|
33
|
+
|
34
|
+
end
|
27
35
|
end
|
28
|
-
|
29
36
|
end
|
30
37
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
data/lib/hydra_hls/engine.rb
CHANGED
data/lib/hydra_hls/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|