Module: VideoTranscoding::HandBrake
Constant Summary collapse
- COMMAND_NAME =
'HandBrakeCLI'
Instance Method Summary collapse
Instance Method Details
#aac_encoder ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/video_transcoding/handbrake.rb', line 43 def aac_encoder properties = Tool.properties(COMMAND_NAME) return properties[:aac_encoder] if properties.has_key? :aac_encoder output = '' begin IO.popen([Tool.use(COMMAND_NAME), '--help'], :err=>[:child, :out]) { |io| output = io.read } rescue SystemCallError => e raise "#{COMMAND_NAME} AAC encoder unknown: #{e}" end fail "#{COMMAND_NAME} failed during execution" unless $CHILD_STATUS.exitstatus == 0 if output =~ /ca_aac/ properties[:aac_encoder] = 'ca_aac' else properties[:aac_encoder] = 'av_aac' end end |
#command_name ⇒ Object
39 40 41 |
# File 'lib/video_transcoding/handbrake.rb', line 39 def command_name Tool.use(COMMAND_NAME) end |
#setup ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/video_transcoding/handbrake.rb', line 13 def setup Tool.provide(COMMAND_NAME, ['--preset-list']) do |output, status, _| fail "#{COMMAND_NAME} failed during execution" unless status == 0 if output =~ /^HandBrake ([^ ]+)/ version = $1 Console.info "#{$MATCH} found..." unless (version =~ /^([0-9]+)\.([0-9]+)/ and (($1.to_i * 100) + $2.to_i) >= 10) or (version =~ /^svn([0-9]+)/ and $1.to_i >= 6536) fail "#{COMMAND_NAME} version 0.10.0 or later required" end end end begin IO.popen([Tool.use(COMMAND_NAME), '--version'], :err=>[:child, :out]) do |io| if io.read =~ /^HandBrake ([^ ]+)/ Console.info "#{$MATCH.strip} found..." end end rescue SystemCallError => e raise "#{COMMAND_NAME} failed during execution: #{e}" end end |