Module: Vidibus::Encoder::Helper::Tools
- Included in:
- Base
- Defined in:
- lib/vidibus/encoder/helper/tools.rb
Instance Method Summary collapse
-
#matching_frame_rate(list) ⇒ Object
Return a matching frame rate from given list.
Instance Method Details
#matching_frame_rate(list) ⇒ Object
Return a matching frame rate from given list. You may use this method to determine which of your valid frame rates fits the input best.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vidibus/encoder/helper/tools.rb', line 9 def matching_frame_rate(list) raise(ArgumentError, 'Argument must be an array') unless list && list.is_a?(Array) input_frame_rate = input.frame_rate list.each do |rate| return rate if rate == input_frame_rate end # Detect the smallest multiple of any list entry lowest_q = nil wanted = nil list.each do |rate| q, r = input_frame_rate.divmod(rate) if r == 0 && (!lowest_q || lowest_q > q) lowest_q = q wanted = rate end end wanted end |