Class: Libis::Format::Converter::VideoConverter
- Inherits:
-
Base
- Object
- Base
- Libis::Format::Converter::VideoConverter
show all
- Defined in:
- lib/libis/format/converter/video_converter.rb
Instance Attribute Summary
Attributes inherited from Base
#flags, #options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
inherited, using_temp, #using_temp
Constructor Details
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
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
def video_encoder(value)
@options[:video_encoder] = value
end
def audio_encoder(value)
@options[:audio_encoder] = value
end
def encoder_options(value)
@options[:encoder_options] = value
end
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
|
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
|