SECONDS = 10 OUTPUT = "/tmp/movie.mov" BASEDIR = File.dirname(File.realpath(__FILE__)) trap(:ALRM) { fork do system "#{BASEDIR}/ffmpeg", '-y', '-i', "/tmp/img_%d.jpg", OUTPUT system "/usr/bin/open", OUTPUT end } i = 0 while true do system "/usr/sbin/screencapture", '-t', 'jpg', "/tmp/img_#{i}.jpg" i = i + 1 sleep 1 end