Class: FFMPEG::EncodingOptions
- Inherits:
-
Hash
- Object
- Hash
- FFMPEG::EncodingOptions
- Defined in:
- lib/ffmpeg/encoding_options.rb
Instance Method Summary collapse
- #height ⇒ Object
-
#initialize(options = {}) ⇒ EncodingOptions
constructor
A new instance of EncodingOptions.
- #params_order(k) ⇒ Object
- #to_a ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ EncodingOptions
Returns a new instance of EncodingOptions.
3 4 5 |
# File 'lib/ffmpeg/encoding_options.rb', line 3 def initialize( = {}) merge!() end |
Instance Method Details
#height ⇒ Object
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_a ⇒ Object
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 |
#width ⇒ Object
37 38 39 |
# File 'lib/ffmpeg/encoding_options.rb', line 37 def width self[:resolution].split("x").first.to_i rescue nil end |