Created
November 11, 2008 11:56
-
-
Save kakra/23812 to your computer and use it in GitHub Desktop.
RVideo Extensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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