3b1b / manim

Animation engine for explanatory math videos
MIT License
71.28k stars 6.26k forks source link

Feature request: skip part of an animation #2217

Open tobiasBora opened 1 month ago

tobiasBora commented 1 month ago

Describe the feature request

I often start an animation from another animation (e.g. copy/pasting the code), and I want to start my new animation from, say, the middle of it (e.g. all objects I need are added and placed where I want), and do something else after. One solution is to use an external program to cut the first X seconds of the video, but not only it is not really practical, but it also takes quite some time and energy to generate this useless first part.

Would it be possible to add something like self.skip_animations() and self.resume_animations() so that I can skip this part in the final render?

Varniex commented 1 month ago

If you want to skip the animations in the final render, use -n flag. For example: -n n0,n1. ManimGL renders all scenes from n0 to n1. If n1 is unspecified, rendering starts from n0 until the end.

tobiasBora commented 1 month ago

Interesting workaround, thanks. It's maybe not as nice to use (you need to count the number of animations etc which is maybe not always obvious… adding labels to animations from the code may be another nice improvement to make it a bit easier to use) but better than nothing. Can we embed this directly in the code so that I don't need to remember this from the commandline?

3b1b commented 1 month ago

One option is to set the Scene parameter ".skip_animations" to be True, then call "self.stop_skipping()" when desired.

During interactive development, I do this with by passing in "-se (line number)" to the call to manim, where the line number is what line of code I want to jump to. Within the interactive development, calling checkpoint_paste(skip=true) will run the pasted code, but skipping the animations.