Skip to content

Instantly share code, notes, and snippets.

@niuage
Last active February 25, 2019 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niuage/f256e26a5f0d9217521d70a95dd779b9 to your computer and use it in GitHub Desktop.
Save niuage/f256e26a5f0d9217521d70a95dd779b9 to your computer and use it in GitHub Desktop.
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