Module: VideoTranscoding::HandBrake

Extended by:
HandBrake
Included in:
HandBrake
Defined in:
lib/video_transcoding/handbrake.rb

Constant Summary collapse

COMMAND_NAME =
'HandBrakeCLI'

Instance Method Summary collapse

Instance Method Details

#aac_encoderObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/video_transcoding/handbrake.rb', line 36

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_nameObject



32
33
34
# File 'lib/video_transcoding/handbrake.rb', line 32

def command_name
  Tool.use(COMMAND_NAME)
end

#setupObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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

    unless output =~ /^HandBrake ([^ ]+)/
      Console.debug output
      fail "#{COMMAND_NAME} version unknown"
    end

    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