Skip to content

Commit d31089b

Browse files
committed
trying to get video to play
1 parent a32f947 commit d31089b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

index.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ from moviepy.video.io.bindings import mplfig_to_npimage
3131
import moviepy.editor as mpy
3232

3333
from IPython.display import Image
34+
from IPython.display import HTML
35+
from base64 import b64encode
3436

3537
# DRAW A FIGURE WITH MATPLOTLIB
3638

@@ -50,9 +52,14 @@ def make_frame_mpl(t):
5052
return mplfig_to_npimage(fig_mpl) # RGB image of the figure
5153

5254
animation =mpy.VideoClip(make_frame_mpl, duration=duration)
53-
animation.write_gif("sinc_mpl.gif", fps=20)
55+
animation.write_videofile("sinc_mpl.mp4", fps=20)
56+
57+
58+
video = open("/home/pyxie/sinc_mpl.mp4", "rb").read()
59+
video_encoded = b64encode(video)
60+
video_tag = '<video controls alt="test" src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
61+
HTML(data=video_tag)
5462

55-
Image(filename='sinc_mpl.gif')
5663
</pre>
5764

5865
Equations:

0 commit comments

Comments
 (0)