Module: Ffmprb
- Defined in:
- lib/ffmprb.rb,
lib/defaults.rb,
lib/ffmprb/file.rb,
lib/ffmprb/util.rb,
lib/ffmprb/filter.rb,
lib/ffmprb/process.rb,
lib/ffmprb/version.rb,
lib/ffmprb/execution.rb,
lib/ffmprb/file/sample.rb,
lib/ffmprb/util/thread.rb,
lib/ffmprb/find_silence.rb,
lib/ffmprb/process/input.rb,
lib/ffmprb/process/output.rb,
lib/ffmprb/process/input/cut.rb,
lib/ffmprb/process/input/loud.rb,
lib/ffmprb/process/input/temp.rb,
lib/ffmprb/process/input/cropped.rb,
lib/ffmprb/process/input/looping.rb,
lib/ffmprb/process/input/channeled.rb,
lib/ffmprb/util/threaded_io_buffer.rb,
lib/ffmprb/process/input/chain_base.rb
Overview
IMPORTANT NOTE ffmprb uses threads internally, however, it is not “thread-safe”
Defined Under Namespace
Modules: Filter, Util Classes: Error, Execution, File, Process
Constant Summary collapse
- ENV_VAR_FALSE_REGEX =
/^(0|no?|false)?$/i- CGA =
'320x200'- QVGA =
'320x240'- HD_720p =
'1280x720'- HD_1080p =
'1920x1080'- VERSION =
'0.9.4'
Class Attribute Summary collapse
-
.debug ⇒ Object
Returns the value of attribute debug.
Class Method Summary collapse
- .execute ⇒ Object
- .find_silence(input_file, output_file) ⇒ Object
- .logger ⇒ Object
- .logger=(logger) ⇒ Object
-
.process(*args, **opts, &blk) ⇒ Object
(also: action!)
TODO limit:.
Class Attribute Details
.debug ⇒ Object
Returns the value of attribute debug.
36 37 38 |
# File 'lib/ffmprb.rb', line 36 def debug @debug end |
Class Method Details
.execute ⇒ Object
16 17 18 19 20 21 |
# File 'lib/ffmprb/execution.rb', line 16 def self.execute return STDERR.puts "Usage: (not quite usual) $ ffmprb streams... < script.ffmprb" unless ARGV.length > 1 && ARGV.grep(/^-/).empty? Execution.new(*ARGV, script: STDIN.read).run end |
.find_silence(input_file, output_file) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ffmprb/find_silence.rb', line 5 def find_silence(input_file, output_file) logger.debug "Finding silence (#{input_file.path}->#{output_file.path})" silence = [] Util.ffmpeg('-i', input_file.path, *, output_file.path). scan(SILENCE_DETECT_REGEX).each do |mark, time| time = time.to_f case mark when 'start' silence << OpenStruct.new(start_at: time) when 'end' if silence.empty? silence << OpenStruct.new(start_at: 0.0, end_at: time) else fail Error, "ffmpeg is being stupid: silence_end with no silence_start" if silence.last.end_at silence.last.end_at = time end else Ffmprb.warn "Unknown silence mark: #{mark}" end end logger.debug "Found silence (#{input_file.path}->#{output_file.path}): [#{silence.map{|t,v| "#{t}: #{v}"}}]" silence end |
.logger ⇒ Object
38 39 40 41 42 |
# File 'lib/ffmprb.rb', line 38 def logger @logger ||= Logger.new(STDERR).tap do |logger| logger.level = debug ? Logger::DEBUG : Logger::INFO end end |
.logger=(logger) ⇒ Object
44 45 46 47 |
# File 'lib/ffmprb.rb', line 44 def logger=(logger) @logger.close if @logger @logger = logger end |
.process(*args, **opts, &blk) ⇒ Object Also known as: action!
TODO limit:
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ffmprb.rb', line 20 def process(*args, **opts, &blk) fail Error, "process: nothing ;( gimme a block!" unless blk process = Process.new(**opts) logger.debug "Starting process with #{args} in #{blk.source_location}" 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 |