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



28
29
30
# File 'lib/ffmpeg/encoding_options.rb', line 28

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

#to_sObject



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

def to_s
  params = collect do |key, value|
    send("convert_#{key}", value) if value && supports_option?(key)
  end

  # 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
  codecs = params.select { |p| p =~ /codec/ }
  presets = params.select { |p| p =~ /\-.pre/ }
  other = params - codecs - presets
  params = codecs + presets + other

  params_string = params.join(" ")
  params_string << " #{convert_aspect(calculate_aspect)}" if calculate_aspect?
  params_string
end

#widthObject



24
25
26
# File 'lib/ffmpeg/encoding_options.rb', line 24

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