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



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/video_transcoding/handbrake.rb', line 57

def aac_encoder
  properties = Tool.properties(COMMAND_NAME)

  unless properties.has_key? :aac_encoder
    if help_text =~ /ca_aac/
      properties[:aac_encoder] = 'ca_aac'
    else
      properties[:aac_encoder] = 'av_aac'
    end
  end

  properties[:aac_encoder]
end

#auto_anamorphicObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/video_transcoding/handbrake.rb', line 43

def auto_anamorphic
  properties = Tool.properties(COMMAND_NAME)

  unless properties.has_key? :auto_anamorphic
    if help_text =~ /auto-anamorphic/
      properties[:auto_anamorphic] = 'auto-anamorphic'
    else
      properties[:auto_anamorphic] = 'strict-anamorphic'
    end
  end

  properties[:auto_anamorphic]
end

#command_nameObject



39
40
41
# File 'lib/video_transcoding/handbrake.rb', line 39

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
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