Sha256: 7f5df2f2323e71c4517c9fced1237d7973704ddf1cdbfb355922bc82924479ca

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

require 'libis/tools/extend/string'
require 'libis/tools/extend/empty'
require 'libis/tools/command'

require 'csv'
require 'libis/format/config'

module Libis
  module Format
    module Tool

      class FFMpeg
        include Singleton
        include ::Libis::Tools::Logger

        def self.run(source, target, options = {})
          self.instance.run source, target, options
        end

        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_path], *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

      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
libis-format-1.0.4 lib/libis/format/tool/ffmpeg.rb
libis-format-1.0.2 lib/libis/format/tool/ffmpeg.rb
libis-format-1.0.1 lib/libis/format/tool/ffmpeg.rb
libis-format-1.0.0 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.74 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.72 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.70 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.69 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.68 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.67 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.66 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.65 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.64 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.63 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.62 lib/libis/format/tool/ffmpeg.rb
libis-format-0.9.50 lib/libis/format/tool/ffmpeg.rb