Skip to content
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

Please remove or weaken run_time validation in Animation class, so as to allow animations with run_time = 0 #4004

Open
puppis opened this issue Nov 9, 2024 · 8 comments · May be fixed by #4017
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)

Comments

@puppis
Copy link

puppis commented Nov 9, 2024

A validation on the value of run_time in the class of Animation has been recently introduced. In the current version I have this is implemented inside the begin method, but this might have already been moved in recent versions.

The problem with this validation is that it does not allow animations with run_time = 0.

For example, with run_time = 0 one could make an object appear instantly. Note that it is not always possible to implement this example behaviour using the add method from Scene: it is conceivable that, sometimes, one may want to have a proper animation object for this, which is then combined with other animations.

Also, having run_time = 0 does not really create any problem with the animation rendering, so, strictly speaking, the validation is not needed. My current ugly solution for this is to override the method begin to bypass this validation.

@puppis puppis added the new feature Enhancement specifically adding a new feature (feature request should be used for issues instead) label Nov 9, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Dev Board Nov 9, 2024
@behackl
Copy link
Member

behackl commented Nov 10, 2024

In the new pyav-based rendering, self.playing an animation that has a run_time of 0 effectively breaks the rendering because a broken partial movie file is written.

Disallowing individual animations with non-positive run times is, by far, the easiest solution to make sure this does not happen. Technically, animations with a run_time of 0 still work, as long as there are other animations in the same play call that push the duration of the written partial movie file to any duration that is at least one frame. It would be possible to split the check, to restrict that individual animation run times need to be non-negative, while every play-call has to process something with an actually positive (and sufficiently long) run time.

Semantically, I am not a big fan of animations with a run time of 0. Can you describe in detail why and for which situation exactly you rely on them? Maybe we could come up with a better solutions than misusing animations.

@puppis
Copy link
Author

puppis commented Nov 10, 2024 via email

@uwezi
Copy link
Contributor

uwezi commented Nov 10, 2024

A simple example, as I said, is to have an animation that makes an object appear (eg. with FadeIn and run_time=0). I cannot use the add method of scene because I want to collect this animation and similar other ones in a group that will later be rendered

Just give this particular animation a runtime of 1/config.frame_rate then it will happen in a single frame in your video.

@chopan050
Copy link
Contributor

Just give this particular animation a runtime of 1/config.frame_rate then it will happen in a single frame in your video.

That gave me an idea: what about an Add or AddMobject animation which, by default, has a run time of 1 / config.frame_rate? I've also found myself wanting to instantly add a Mobject in the middle of an AnimationGroup.

@puppis
Copy link
Author

puppis commented Nov 10, 2024

Just give this particular animation a runtime of 1/config.frame_rate then it will happen in a single frame in your video.

Unfortunately this will not work for me: I need the run times of the animations to be precise, since for instance in a Succession Animation those tiny durations will sum up, and in a parallel Animation one will easily lose synchronisation.

As far as I understood the problem mentioned is about the duration of a whole rendered animation; in my case this is the result of several parallel and succession animations, some of which must have run_time = 0. I also understand that validating every single animation is the simplest thing to do, but in my opinion it is not the correct fix.

@behackl
Copy link
Member

behackl commented Nov 14, 2024

Just to document this here as well: we have discussed this some more; we intend to change the run time check for Animation to only check that run_time >= 0, while introducing a separate check for Scene.play that makes sure the duration of any passed groups of animations is at least 1 / config.frame_rate.

Help with changing the current implementation is appreciated!

@puppis
Copy link
Author

puppis commented Nov 14, 2024 via email

@chopan050
Copy link
Contributor

I just made a pull request addressing this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature Enhancement specifically adding a new feature (feature request should be used for issues instead)
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

4 participants