Skip to content

Commit

Permalink
Added progress support for Lame
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien committed Jun 30, 2010
1 parent b344e0a commit 39e0725
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/rvideo/tools/lame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,32 @@ def tool_command
'lame'
end


def execute_with_progress(&block)
RVideo.logger.info("\nExecuting Command: #{@command}\n")
do_execute_with_progress(@command, &block)
rescue RVideo::CommandExecutor::ProcessHungError
raise TranscoderError, "Transcoder hung."
end

def do_execute_with_progress(command,&block)
@raw_result = ''
CommandExecutor::execute_with_block(command, "\r") do |line|
progress = parse_progress(line)
block.call(progress) if block && progress
@raw_result += line + "\r"
end
end

def parse_progress(line)
if line =~ /\((\d+)\%\)/
p = $1
p = 100 if p && (p.to_i > 100)
end
p
end


private

def parse_result(result)
Expand Down

0 comments on commit 39e0725

Please sign in to comment.