3b1b / manim

Animation engine for explanatory math videos
MIT License
61.93k stars 5.77k forks source link

How to run multiple scenes #1086

Open lakeside-park opened 4 years ago

lakeside-park commented 4 years ago

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, ]

TonyCrane commented 4 years ago

You can use a video editing tool.

Or try this:

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

And render scene.

lakeside-park commented 4 years ago

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()

yachty66 commented 2 years ago

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

machinelurning commented 2 years ago

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.

thornoar commented 1 year ago

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)
WalterSmuts commented 1 year ago

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

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