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, #initialize, #using_temp, using_temp
Class Method Details
12
13
14
|
# File 'lib/libis/format/converter/video_converter.rb', line 12
def self.input_types
i[WEBM MP4 MPG MKV MJP2 QTFF AVI OGGV WMV DV FLV SWF]
end
|
.output_types(format = nil) ⇒ Object
16
17
18
19
20
|
# File 'lib/libis/format/converter/video_converter.rb', line 16
def self.output_types(format = nil)
return [] unless input_types.include?(format)
i[GIF WEBM MP4 MPG MKV MJP2 QTFF AVI OGGV WMV DV FLV SWF]
end
|
Instance Method Details
#assemble_and_convert(sources, target) ⇒ Object
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/libis/format/converter/video_converter.rb', line 185
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
58
59
60
|
# File 'lib/libis/format/converter/video_converter.rb', line 58
def audio_bitrate(value)
@options[:audio_bitrate] = value.to_s
end
|
#audio_channels(value) ⇒ Object
30
31
32
|
# File 'lib/libis/format/converter/video_converter.rb', line 30
def audio_channels(value)
@options[:audio_channels] = value.to_s
end
|
#audio_codec(codec) ⇒ Object
34
35
36
|
# File 'lib/libis/format/converter/video_converter.rb', line 34
def audio_codec(codec)
@options[:audio_codec] = codec
end
|
#audio_preset(name) ⇒ Object
138
139
140
|
# File 'lib/libis/format/converter/video_converter.rb', line 138
def audio_preset(name)
@options[:audio_preset] = name
end
|
#audio_quality(value) ⇒ Object
50
51
52
|
# File 'lib/libis/format/converter/video_converter.rb', line 50
def audio_quality(value)
@options[:audio_quality] = value.to_s
end
|
#constant_rate_factor(value) ⇒ Object
66
67
68
|
# File 'lib/libis/format/converter/video_converter.rb', line 66
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
# File 'lib/libis/format/converter/video_converter.rb', line 159
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
{
files: [target],
converter: self.class.name
}
end
|
#duration(seconds) ⇒ Object
46
47
48
|
# File 'lib/libis/format/converter/video_converter.rb', line 46
def duration(seconds)
@options[:duration] = seconds.to_s
end
|
26
27
28
|
# File 'lib/libis/format/converter/video_converter.rb', line 26
def format(format)
@options[:format] = format
end
|
#frame_rate(value) ⇒ Object
70
71
72
|
# File 'lib/libis/format/converter/video_converter.rb', line 70
def frame_rate(value)
@options[:frame_rate] = value.to_s
end
|
#preset(name) ⇒ Object
133
134
135
|
# File 'lib/libis/format/converter/video_converter.rb', line 133
def preset(name)
@options[:preset] = name
end
|
#quiet(value) ⇒ Object
22
23
24
|
# File 'lib/libis/format/converter/video_converter.rb', line 22
def quiet(value)
@flags[:quiet] = !!value
end
|
#sampling_freq(value) ⇒ Object
74
75
76
|
# File 'lib/libis/format/converter/video_converter.rb', line 74
def sampling_freq(value)
@options[:sampling_freq] = value.to_s
end
|
#scale(width_x_height) ⇒ Object
78
79
80
|
# File 'lib/libis/format/converter/video_converter.rb', line 78
def scale(width_x_height)
@options[:scale] = width_x_height
end
|
#start(seconds) ⇒ Object
42
43
44
|
# File 'lib/libis/format/converter/video_converter.rb', line 42
def start(seconds)
@options[:start] = seconds.to_s
end
|
#video_bitrate(value) ⇒ Object
62
63
64
|
# File 'lib/libis/format/converter/video_converter.rb', line 62
def video_bitrate(value)
@options[:video_bitrate] = value.to_s
end
|
#video_codec(codec) ⇒ Object
38
39
40
|
# File 'lib/libis/format/converter/video_converter.rb', line 38
def video_codec(codec)
@options[:video_codec] = codec
end
|
#video_preset(name) ⇒ Object
143
144
145
|
# File 'lib/libis/format/converter/video_converter.rb', line 143
def video_preset(name)
@options[:video_preset] = name
end
|
#video_quality(value) ⇒ Object
54
55
56
|
# File 'lib/libis/format/converter/video_converter.rb', line 54
def video_quality(value)
@options[:video_quality] = value.to_s
end
|
#watermark_image(file) ⇒ Object
83
84
85
|
# File 'lib/libis/format/converter/video_converter.rb', line 83
def watermark_image(file)
@options[:watermark_image] = file
end
|
#watermark_opacity(value) ⇒ Object
120
121
122
|
# File 'lib/libis/format/converter/video_converter.rb', line 120
def watermark_opacity(value)
@options[:watermark_opacity] = value.to_f
end
|
#watermark_position(value) ⇒ Object
115
116
117
|
# File 'lib/libis/format/converter/video_converter.rb', line 115
def watermark_position(value)
@options[:watermark_position] = value
end
|
#watermark_text(value) ⇒ Object
88
89
90
|
# File 'lib/libis/format/converter/video_converter.rb', line 88
def watermark_text(value)
@options[:watermark_text] = value
end
|
#watermark_text_color(value) ⇒ Object
99
100
101
|
# File 'lib/libis/format/converter/video_converter.rb', line 99
def watermark_text_color(value)
@options[:watermark_text_color] = value
end
|
#watermark_text_shadow_color(value) ⇒ Object
104
105
106
|
# File 'lib/libis/format/converter/video_converter.rb', line 104
def watermark_text_shadow_color(value)
@options[:watermark_text_shadow_color] = value
end
|
#watermark_text_shadow_offset(value) ⇒ Object
If the offset is set to 0, no shadow will be printed
110
111
112
|
# File 'lib/libis/format/converter/video_converter.rb', line 110
def watermark_text_shadow_offset(value)
@options[:watermark_text_offset] = value.to_i
end
|
#watermark_text_size(value) ⇒ Object
Note that the font is selected by the Config setting
94
95
96
|
# File 'lib/libis/format/converter/video_converter.rb', line 94
def watermark_text_size(value)
@options[:watermark_text_size] = value.to_i
end
|
#web_stream(value) ⇒ Object
125
126
127
128
129
130
|
# File 'lib/libis/format/converter/video_converter.rb', line 125
def web_stream(value)
return unless value
@options[:video_codec] = 'h264'
@options[:audio_codec] = 'acc'
end
|