Class: FFMPEG::EncodingOptions

Inherits:
Hash
  • Object
show all
Defined in:
lib/ffmpeg/encoding_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ EncodingOptions

Returns a new instance of EncodingOptions.



3
4
5
# File 'lib/ffmpeg/encoding_options.rb', line 3

def initialize(options = {})
  merge!(options)
end

Instance Method Details

#heightObject



41
42
43
# File 'lib/ffmpeg/encoding_options.rb', line 41

def height
  self[:resolution].split("x").last.to_i rescue nil
end

#params_order(k) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ffmpeg/encoding_options.rb', line 7

def params_order(k)
  if k =~ /watermark$/
    0
  elsif k =~ /watermark/
    1
  elsif k =~ /codec/
    2
  elsif k =~ /preset/
    3
  else
    4
  end
end

#to_aObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ffmpeg/encoding_options.rb', line 21

def to_a
  params = []

  # codecs should go before the presets so that the files will be matched successfully
  # all other parameters go after so that we can override whatever is in the preset
  keys.sort_by{|k| params_order(k) }.each do |key|

    value   = self[key]
    a = send("convert_#{key}", value) if value && supports_option?(key)
    params += a unless a.nil?
  end

  params += convert_aspect(calculate_aspect) if calculate_aspect?
  params.map(&:to_s)
end

#widthObject



37
38
39
# File 'lib/ffmpeg/encoding_options.rb', line 37

def width
  self[:resolution].split("x").first.to_i rescue nil
end