manim icon indicating copy to clipboard operation
manim copied to clipboard

How to run multiple scenes

Open lakeside-park opened this issue 5 years ago • 6 comments

looking at a file like all_part_1_scenes.py. Is that intended to be used to create 1 video when all scenes have been debugged and working? I have created 2 scenes in 2 files and want to run one after the other to create one video. I made a file similar to all_part_1_scenes.py which looks like this:

But when I run the high level all_scene file - i get the option of 1 or 2 to run scene or scene2. How can I run scene2 right after scene(1) in the same video? Or is the idea that each scene in all_part_1_scenes gets run and generates its own video then I use a video editing tool to link together all the separate scene video files?

from MIT_Logo_Scene import * from MIT_Logo_Scene2 import *

SCENES_IN_ORDER = [ MIT_Logo_Scene, MIT_Logo_Scene2, ]

lakeside-park avatar May 19 '20 17:05 lakeside-park

You can use a video editing tool.

Or try this:

class scene(Scene):
    def construct(self):
        scene1.construct()
        scene2.construct()

And render scene.

TonyCrane avatar May 20 '20 00:05 TonyCrane

thanks for that...I changed the file to shown below and getting error - not sure what I do with your suggestion

from MIT_Logo_Scene import * from MIT_Logo_Scene2 import *

class scene(Scene): def construct(self): MIT_Logo_Scene.construct() MIT_Logo_Scene2.construct()

lakeside-park avatar May 21 '20 23:05 lakeside-park

Still not sure how to run all the created scenes together. Do people really cut their Manim videos with an editing tool?

yachty66 avatar Mar 18 '22 17:03 yachty66

Still not sure how to run all the created scenes together. Do people really cut their Manim videos with an editing tool?

Yes, it's what I do. Much easier than hard-coding self.wait() etc. It's much simpler than most people think and there are a lot of free options. Let me know if you need suggestions.

machinelurning avatar Apr 12 '22 02:04 machinelurning

You can use a video editing tool.

Or try this:

class scene(Scene):
    def construct(self):
        scene1.construct()
        scene2.construct()

And render scene.

Actually, in my case this didn't work. Another method would be to create multiple external methods corresponding to your scenes, then create one scene, and consecutively apply those methods to it:

def FirstScene (scene : Scene):
       # animate stuff

def SecondScene (scene : Scene):
      # animate stuff

class Main (Scene):
         def construct (self):
               FirstScene(self)
               SecondScene(self)

thornoar avatar Oct 09 '22 20:10 thornoar

For those of you interested I've got the following working nicely:

  • Run each scene individually by specifying target in manim
  • One of the scenes is a CombineScene
  • The combine scene has animations to fade out between scenes
def fade_out(scene: Scene):
    animations = []
    for mobject in scene.mobjects:
        animations.append(FadeOut(mobject))
    scene.play(*animations)


class CombinedScene(Scene):
    def construct(self):
        scenes = [] # TODO: Add scenes here
        for scene in scenes:
            scene.construct(self)
            fade_out(self)

WalterSmuts avatar Jul 16 '23 18:07 WalterSmuts