Created
January 20, 2009 21:21
-
-
Save jnstq/49673 to your computer and use it in GitHub Desktop.
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
Signal.trap("CHLD") do | |
puts "Child proccses terminated" | |
end | |
filename, size, frames, timecode, = "", 0, 0, "" | |
run_command = "dvgrab -noavc -showstatus testfilm 2>&1" | |
pipe = nil | |
threads = [] | |
threads << Thread.new do | |
# See http://kpumuk.info/ruby-on-rails/encoding-media-files-in-ruby-using-ffmpeg-mencoder-with-progress-tracking/ | |
pipe = IO.popen(run_command) | |
pipe.each("\r") do |line| # \r allt vilken sträng som helst där... | |
if line =~ %r["(\w+[.]\w+)":\s+(.*)\s+MiB\s+(\d+)\s+frames\s+timecode\s+(.*)\s+date] | |
# 1. testfilm054.dv | |
# 2. 34.06 | |
# 3. 248 | |
# 4. 00:27:44.19 | |
filename, size, frames, timecode = $1, $2, $3, $4 | |
end | |
end | |
end | |
threads << Thread.new{ loop { Thread.stop unless pipe; sleep 1; puts "Size: #{size} Timecode: #{timecode}"; } } | |
puts "The End..." | |
puts pipe.inspect | |
puts pipe.pid | |
sleep 10 | |
puts "About to kill" | |
Process.kill('HUP', pipe.pid) | |
pipe.close | |
#pipe = nil | |
puts Thread.list.inspect | |
puts threads.inspect | |
#threads.each {|thr| thr.join } | |
#at_exit do | |
# threads.each {|thr| thr.join } | |
#end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment