Skip to content

Instantly share code, notes, and snippets.

@kakra
Created November 11, 2008 11:56
Show Gist options
  • Save kakra/23812 to your computer and use it in GitHub Desktop.
Save kakra/23812 to your computer and use it in GitHub Desktop.
RVideo Extensions
module RVideo
module Tools
class Mp4creator
include AbstractTool::InstanceMethods
attr_reader :raw_metadata
def tool_command
'mp4creator'
end
private
def parse_result(result)
if result.empty?
@raw_metadata = "OK"
return true
end
if m = /MP4ERROR: MP4Open: failed: No such file or directory\n/.match(result)
raise TranscoderError::InputFileNotFound
end
if m = /ReadAtom: invalid atom size/.match(result)
raise TranscoderError::InvalidFile, "input must be a valid MP4 file"
end
if m = /usage: mp4creator /i.match(result)
raise TranscoderError::InvalidCommand, "command printed mp4creator help text (and presumably didn't execute)"
end
raise TranscoderError::UnexpectedResult, result
end
end
end
end
require 'rvideo'
module RVideo # :nodoc:
module Tools # :nodoc:
class AbstractTool
module InstanceMethods
alias :original_execute :execute
def execute
original_command = @command
result = nil
begin
@command = "nice #{@command}"
result = original_execute
ensure
@command = original_command
end
result
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment