Created
December 4, 2014 12:50
-
-
Save aont/e42740023d7d39dcbcfa to your computer and use it in GitHub Desktop.
on-the-fly making gnuplot movie
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
| #!/usr/bin/ruby | |
| # coding: utf-8 | |
| require 'open3' | |
| Open3.popen3('gnuplot') do |gp_in, gp_out, gp_err| | |
| gp_in.puts "set term png" | |
| gp_in.puts "set output \"| ffmpeg -y -f image2pipe -i - -vcodec copy out.mp4 >ffmpeg.log 2>&1" | |
| 500.times do |i| | |
| delta = 0.1*i | |
| gp_in.puts "plot sin(x+%g)" % delta | |
| gp_in.puts "print \"%d\"" % i | |
| puts gp_err.gets | |
| end | |
| gp_in.puts "set output" | |
| gp_in.puts "print \"end\"" | |
| puts gp_err.gets | |
| gp_in.puts "exit" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment