-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Animation conversion to HTML5 video #4785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation conversion to HTML5 video #4785
Conversation
This paves the way for displaying animations in IPython notebooks.
This is configurable using rc params, and defaults to off.
I really wish I had gotten this in sooner for 1.5.... |
self._base64_video = vid64.decode('ascii') | ||
self._video_size = 'width="{0}" height="{1}"'.format( | ||
*writer.frame_size) | ||
os.remove(f.name) # Now we can remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to remove an open file on all platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so--good catch. I don't think there's any reason to move that line out of the with
.
I like it and don't have any problem with it being merged late. It is a new completely optional feature and we can always mark it as experimental if need be. I do think that it needs an entry in whats new thou. There are a few usability problems with the nbagg backend. The nbagg backend in interactive mode will show the notebook window with the animation along with the repr_html (if that is enabled) producing double output. But that may be more of an issue with the nbagg backend? |
Thanks, I'll address those comments shortly, as well as a few other tweaks. Regarding nbagg, the original version I'm adapting called It looks like you can work around this by putting the animation in a different cell than the figure creation. |
Great. It might be possible in the long term to be more cleaver about when nbagg displays a figure but that is out of the scope of this PR in any case. I ended up wrapping the animation with It might also be worth mentioning somewhere that you can do: from IPython.display import HTML
HTML(ani. to_html5_video()) If you don't want to enable the repr_html |
I talked to @minrk about a related issue at Scipy, but I don't remember the exact outcome of that conversation. |
👍 Looks good to me @tacaswell Do we want to do any kind of feature freeze or are we ok to merge this? @jamespjh this may be of interest to you |
Merge it, i want to break feature freeze in a couple of other things that On Mon, Jul 27, 2015, 2:28 PM Jens Hedegaard Nielsen <
|
Animation conversion to HTML5 video
cc @jclark754 @lesserwhirls |
This adds a method to render animations as an HTML5 video tag (h264 encoded video, base64-encoded directly into the tag.) It then adds the IPython display hook to allow it to automatically render in the notebook, though by default it is off. The use of the rcparam can be extended to also include JSAnimation.