Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
jenshnielsen merged 5 commits into matplotlib:master from dopplershift:anim-html5-video
Jul 27, 2015

Conversation

Copy link
Contributor

@dopplershift dopplershift commented Jul 24, 2015

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.

This paves the way for displaying animations in IPython notebooks.
This is configurable using rc params, and defaults to off.
Copy link
Contributor Author

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
Copy link
Member

@jenshnielsen jenshnielsen Jul 26, 2015

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?

Copy link
Contributor Author

@dopplershift dopplershift Jul 27, 2015

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.

Copy link
Member

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?

Copy link
Contributor Author

Thanks, I'll address those comments shortly, as well as a few other tweaks.

Regarding nbagg, the original version I'm adapting called plt.close() to address the double display problem. Personally, I think I'd end up working around this behavior as often as I'd want it. I can't think of any less draconian way to eliminate the display of the figure.

It looks like you can work around this by putting the animation in a different cell than the figure creation.

Copy link
Member

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 plt.ioff() and plt.ion() to prevent the nbagg backend in showing a figure automatically.

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

Copy link
Member

I talked to @minrk about a related issue at Scipy, but I don't remember the exact outcome of that conversation.

Copy link
Member

👍 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

Copy link
Member

Merge it, i want to break feature freeze in a couple of other things that
are far more major changes

On Mon, Jul 27, 2015, 2:28 PM Jens Hedegaard Nielsen <
notifications@github.com> wrote:

[image: 👍] Looks good to me

@tacaswell https://github.com/tacaswell Do we want to do any kind of
feature freeze or are we ok to merge this?

@jamespjh https://github.com/jamespjh this may be of interest to you


Reply to this email directly or view it on GitHub
#4785 (comment)
.

jenshnielsen added a commit that referenced this pull request Jul 27, 2015
@jenshnielsen jenshnielsen merged commit 271a646 into matplotlib:master Jul 27, 2015
@dopplershift dopplershift deleted the anim-html5-video branch July 28, 2015 03:06
Copy link
Contributor Author

cc @jclark754 @lesserwhirls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
v1.5.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /