20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/libis/format/tool/ffmpeg.rb', line 20
def run(source, target, options = {})
opts = []
opts += options[:global] unless options[:global].empty?
opts += options[:input] unless options[:input].empty?
opts << '-i' << source
opts += options[:filter] unless options[:filter].empty?
opts += options[:output] unless options[:output].empty?
opts << target
timeout = Libis::Format::Config[:timeouts][:ffmpeg]
result = Libis::Tools::Command.run(
Libis::Format::Config[:ffmpeg_cmd], *opts,
timeout: timeout,
kill_after: timeout * 2
)
raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout]
raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0
warn "FFMpeg warnings: #{(result[:err] + result[:out]).join("\n")}" unless result[:err].empty?
result[:out]
end
|