Method: HandBrake::CLI#output
- Defined in:
- lib/handbrake/cli.rb
#output(filename, options = {})
This method returns an undefined value.
Performs a conversion. This method immediately begins the transcoding process; set all other options first.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/handbrake/cli.rb', line 86 def output(filename, ={}) overwrite = .delete :overwrite case overwrite when true, nil # no special behavior when false raise FileExistsError, filename if File.exist?(filename) when :ignore if File.exist?(filename) trace "Ignoring transcode to #{filename.inspect} because it already exists" return end else raise "Unsupported value for :overwrite: #{overwrite.inspect}" end atomic = .delete :atomic interim_filename = case atomic when true partial_filename(filename) when String partial_filename(File.join(atomic, File.basename(filename))) when false, nil filename else fail "Unsupported value for :atomic: #{atomic.inspect}" end unless .empty? raise "Unknown options for output: #{.keys.inspect}" end run('--output', interim_filename) if filename != interim_filename replace = if File.exist?(filename) trace "#{filename.inspect} showed up during transcode" case overwrite when false raise FileExistsError, filename when :ignore trace "- will leave #{filename.inspect} as is; copy #{interim_filename.inspect} manually if you want to replace it" false else trace '- will replace with new transcode' true end else true end FileUtils.mv(interim_filename, filename, :verbose => trace?) if replace end end |