Class: Abrizer::AdaptationFinder
- Inherits:
-
Object
- Object
- Abrizer::AdaptationFinder
- Defined in:
- lib/abrizer/adaptation_finder.rb
Overview
TODO: AdaptationFinder is incomplete. Basically what we want to do is to find out the height, width, and aspect ratio of the original and then determine which adaptations to create. So for a 3:2 video we’ll have 4 adaptations but ought to only create ones that are the same size and smaller than the input file. Adaptations that are larger should not be created. So first we find the aspect ratio to see the value adaptations we could apply and then we select the ones that are the same width and smaller. If there is not an exact match for the All of the aspect ratios here are given based on real files that have come through our workflow, so there might be some missing.
Instance Attribute Summary collapse
-
#adaptations ⇒ Object
readonly
Returns the value of attribute adaptations.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
Instance Method Summary collapse
-
#ar_16_9_adaptations ⇒ Object
The bitrates here are based on H.264 encoding.
-
#ar_4_3_adaptations ⇒ Object
The bitrates here are based on H.264 encoding.
-
#find_adaptations ⇒ Object
TODO: analyze the incoming file and determine which preset to use.
-
#initialize(filename) ⇒ AdaptationFinder
constructor
A new instance of AdaptationFinder.
Constructor Details
#initialize(filename) ⇒ AdaptationFinder
Returns a new instance of AdaptationFinder.
14 15 16 17 18 |
# File 'lib/abrizer/adaptation_finder.rb', line 14 def initialize(filename) @filename = filename @informer = Abrizer::FfprobeInformer.new(filename) find_adaptations end |
Instance Attribute Details
#adaptations ⇒ Object (readonly)
Returns the value of attribute adaptations.
13 14 15 |
# File 'lib/abrizer/adaptation_finder.rb', line 13 def adaptations @adaptations end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
13 14 15 |
# File 'lib/abrizer/adaptation_finder.rb', line 13 def info @info end |
Instance Method Details
#ar_16_9_adaptations ⇒ Object
The bitrates here are based on H.264 encoding.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/abrizer/adaptation_finder.rb', line 46 def ar_16_9_adaptations # Average video bitrate from here: https://bitmovin.com/video-bitrate-streaming-hls-dash/ [ {width: 256, height: 144, bitrate: 200}, {width: 512, height: 288, bitrate: 400}, {width: 768, height: 432, bitrate: 800}, {width: 1024, height: 576, bitrate: 1200}, {width: 1280, height: 720, bitrate: 2400}, {width: 1920, height: 1080, bitrate: 4800}, ] end |
#ar_4_3_adaptations ⇒ Object
The bitrates here are based on H.264 encoding.
36 37 38 39 40 41 42 43 |
# File 'lib/abrizer/adaptation_finder.rb', line 36 def ar_4_3_adaptations [ {width: 224, height: 168, bitrate: 200}, {width: 448, height: 336, bitrate: 400}, {width: 640, height: 480, bitrate: 800}, {width: 720, height: 540, bitrate: 1000}, ] end |
#find_adaptations ⇒ Object
TODO: analyze the incoming file and determine which preset to use
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/abrizer/adaptation_finder.rb', line 21 def find_adaptations raw_adaptations = case @informer.display_aspect_ratio when "4:3" ar_4_3_adaptations when "16:9" ar_16_9_adaptations else puts "Unable to find appropriate adaptation set!" exit end adaptations = raw_adaptations.map{|adaptation| Abrizer::Adaptation.new(adaptation)} @adaptations = adaptations.select{|adaptation| adaptation.width <= @informer.width} end |