Class: Libis::Format::Converter::VideoConverter
- Defined in:
- lib/libis/format/converter/video_converter.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #assemble_and_convert(sources, target) ⇒ Object
- #audio_bitrate(value) ⇒ Object
- #audio_channels(value) ⇒ Object
- #audio_codec(codec) ⇒ Object
- #audio_preset(name) ⇒ Object
- #audio_quality(value) ⇒ Object
- #constant_rate_factor(value) ⇒ Object
-
#convert(source, target, _format, opts = {}) ⇒ Object
def video_encoder(value) @options = value end.
- #duration(seconds) ⇒ Object
- #format(format) ⇒ Object
- #frame_rate(value) ⇒ Object
-
#initialize ⇒ VideoConverter
constructor
A new instance of VideoConverter.
- #preset(name) ⇒ Object
- #quiet(v) ⇒ Object
- #sampling_freq(value) ⇒ Object
- #scale(width_x_height) ⇒ Object
- #start(seconds) ⇒ Object
- #video_bitrate(value) ⇒ Object
- #video_codec(codec) ⇒ Object
- #video_preset(name) ⇒ Object
- #video_quality(value) ⇒ Object
- #web_stream(value) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize ⇒ VideoConverter
Returns a new instance of VideoConverter.
21 22 23 |
# File 'lib/libis/format/converter/video_converter.rb', line 21 def initialize super end |
Class Method Details
.input_types ⇒ Object
12 13 14 |
# File 'lib/libis/format/converter/video_converter.rb', line 12 def self.input_types [:WEBM, :M4V, :MPEG, :MJP2, :QTFF, :AVI, :OGGV, :WMV, :DV, :FLASH] end |
.output_types(format = nil) ⇒ Object
16 17 18 19 |
# File 'lib/libis/format/converter/video_converter.rb', line 16 def self.output_types(format = nil) return [] unless input_types.include?(format) [:GIF, :AVI, :FLV, :MKV, :MOV, :MP4, :MPG, :OGGV, :SWF, :WEBM, :WMV] end |
Instance Method Details
#assemble_and_convert(sources, target) ⇒ Object
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/libis/format/converter/video_converter.rb', line 140 def assemble_and_convert(sources, target) Tempfile.create(%w(list .txt)) do |f| sources.each {|src| f.puts src} opts[:global] ||= [] opts[:global] += %w(-f concat) f.close target = convert_file(f.to_path, target) end target end |
#audio_bitrate(value) ⇒ Object
61 62 63 |
# File 'lib/libis/format/converter/video_converter.rb', line 61 def audio_bitrate(value) @options[:audio_bitrate] = value.to_s end |
#audio_channels(value) ⇒ Object
33 34 35 |
# File 'lib/libis/format/converter/video_converter.rb', line 33 def audio_channels(value) @options[:audio_channels] = value.to_s end |
#audio_codec(codec) ⇒ Object
37 38 39 |
# File 'lib/libis/format/converter/video_converter.rb', line 37 def audio_codec(codec) @options[:audio_codec] = codec end |
#audio_preset(name) ⇒ Object
96 97 98 |
# File 'lib/libis/format/converter/video_converter.rb', line 96 def audio_preset(name) @options[:audio_preset] = name end |
#audio_quality(value) ⇒ Object
53 54 55 |
# File 'lib/libis/format/converter/video_converter.rb', line 53 def audio_quality(value) @options[:audio_quality] = value.to_s end |
#constant_rate_factor(value) ⇒ Object
69 70 71 |
# File 'lib/libis/format/converter/video_converter.rb', line 69 def constant_rate_factor(value) @options[:crf] = value.to_s end |
#convert(source, target, _format, opts = {}) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/libis/format/converter/video_converter.rb', line 116 def convert(source, target, _format, opts = {}) super FileUtils.mkpath(File.dirname(target)) if source.is_a? Array assemble_and_convert(source, target) elsif File.directory?(source) sources = Dir[File.join(source, '**', '*')].reject {|p| File.directory? p} assemble_and_convert(sources, target) else convert_file(source, target) end target end |
#duration(seconds) ⇒ Object
49 50 51 |
# File 'lib/libis/format/converter/video_converter.rb', line 49 def duration(seconds) @options[:duration] = seconds.to_s end |
#format(format) ⇒ Object
29 30 31 |
# File 'lib/libis/format/converter/video_converter.rb', line 29 def format(format) @options[:format] = format end |
#frame_rate(value) ⇒ Object
73 74 75 |
# File 'lib/libis/format/converter/video_converter.rb', line 73 def frame_rate(value) @options[:frame_rate] = value.to_s end |
#preset(name) ⇒ Object
92 93 94 |
# File 'lib/libis/format/converter/video_converter.rb', line 92 def preset(name) @options[:preset] = name end |
#quiet(v) ⇒ Object
25 26 27 |
# File 'lib/libis/format/converter/video_converter.rb', line 25 def quiet(v) @flags[:quiet] = !!v end |
#sampling_freq(value) ⇒ Object
77 78 79 |
# File 'lib/libis/format/converter/video_converter.rb', line 77 def sampling_freq(value) @options[:sampling_freq] = value.to_s end |
#scale(width_x_height) ⇒ Object
81 82 83 |
# File 'lib/libis/format/converter/video_converter.rb', line 81 def scale(width_x_height) @options[:scale] = width_x_height end |
#start(seconds) ⇒ Object
45 46 47 |
# File 'lib/libis/format/converter/video_converter.rb', line 45 def start(seconds) @options[:start] = seconds.to_s end |
#video_bitrate(value) ⇒ Object
65 66 67 |
# File 'lib/libis/format/converter/video_converter.rb', line 65 def video_bitrate(value) @options[:video_bitrate] = value.to_s end |
#video_codec(codec) ⇒ Object
41 42 43 |
# File 'lib/libis/format/converter/video_converter.rb', line 41 def video_codec(codec) @options[:video_codec] = codec end |
#video_preset(name) ⇒ Object
100 101 102 |
# File 'lib/libis/format/converter/video_converter.rb', line 100 def video_preset(name) @options[:video_preset] = name end |
#video_quality(value) ⇒ Object
57 58 59 |
# File 'lib/libis/format/converter/video_converter.rb', line 57 def video_quality(value) @options[:video_quality] = value.to_s end |
#web_stream(value) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/libis/format/converter/video_converter.rb', line 85 def web_stream(value) if value @options[:video_codec] = 'h264' @options[:audio_codec] = 'acc' end end |