Sha256: f290eac9c86871a4b04b38ceb59144734355a6765647b034655d3e04422b242d

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

require 'ffmprb/execution'
require 'ffmprb/file'
require 'ffmprb/filter'
require 'ffmprb/find_silence'
require 'ffmprb/process'
require 'ffmprb/util'
require 'ffmprb/version'

require 'logger'

module Ffmprb

  ENV_VAR_FALSE_REGEX = /^(0|no?|false)?$/i

  QVGA = '320x240'
  HD_720p = '1280x720'
  HD_1080p = '1920x1080'

  class Error < StandardError
  end

  Util.ffmpeg_cmd = ['ffmpeg']
  Util.ffprobe_cmd = ['ffprobe']

  Process.duck_audio_hi = 0.9
  Process.duck_audio_lo = 0.1
  Process.duck_audio_transition_sec = 1
  Process.duck_audio_silent_min_sec = 3
  Filter.silence_noise_max_db = -40

  Util::IoBuffer.blocks_max = 1024
  Util::IoBuffer.block_size = 64*1024
  Util::IoBuffer.timeout = 9

  class << self

    # NOTE the form with the block returns the result of #run
    # NOTE the form without the block returns the process (before it is run)
    def process(*args, &blk)
      logger.debug "Starting process with #{args} in #{blk.source_location}"
      process = Process.new
      return process  unless blk

      process.instance_exec *args, &blk
      logger.debug "Initialized process with #{args} in #{blk.source_location}"

      process.run.tap do
        logger.debug "Finished process with #{args} in #{blk.source_location}"
      end
    end
    alias :action! :process  # ;)

    attr_accessor :debug

    def logger
      @logger ||= Logger.new(STDERR).tap do |logger|
        logger.level = debug ? Logger::DEBUG : Logger::INFO
      end
    end

    def logger=(logger)
      @logger.close  if @logger
      @logger = logger
    end

  end

end

Ffmprb.debug = ENV.fetch('FFMPRB_DEBUG', '') !~ Ffmprb::ENV_VAR_FALSE_REGEX

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffmprb-0.7.0 lib/ffmprb.rb