Created
November 8, 2017 06:00
-
-
Save kjunichi/d81113a4abafe21d2c938567d5bb3e13 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
using PyCall | |
@pyimport matplotlib.animation as anim | |
using PyPlot | |
x = [0:pi/50:2pi;] | |
function showanim(filename) | |
base64_video = base64encode(open(filename)) | |
display("text/html", """<video controls src="data:video/x-m4v;base64,$base64_video">""") | |
end | |
fig = figure(figsize=(4,4)) | |
function make_frame(i) | |
clf() | |
axis("off") | |
y = sin.(x*i/10); | |
plot(x,y) | |
end | |
withfig(fig) do | |
myanim = anim.FuncAnimation(fig, make_frame, frames=50, interval=20) | |
myanim[:save]("test0.mp4", bitrate=-1, extra_args=["-vcodec", "libx264", "-pix_fmt", "yuv420p"]) | |
end | |
showanim("test0.mp4") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment