Last active
February 25, 2019 19:02
-
-
Save niuage/f256e26a5f0d9217521d70a95dd779b9 to your computer and use it in GitHub Desktop.
This file contains 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
pipe = "kikou.png" | |
(1..100).step(0.5) do |time| | |
begin | |
retries ||= 0 | |
Timeout::timeout(5) do | |
fork do | |
`#{command(time, score_crop_options, pipe)}` # runs ffmpeg, writes frame into `pipe` | |
exit | |
end | |
# read image from pipe. | |
# blocking (until ffmpeg writes into the pipe) | |
image = read_image | |
# do stuff with image | |
end | |
rescue Timeout::Error => e | |
retry if (retries += 1) < 3 | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment