manim_zh_doc
  • 如何安装manim
  • 快速使用
  • 最佳实践
    • Basic Concepts
      • ManimCELogo
      • BraceAnnotation
      • VectorArrow
      • GradientImageFromArray
      • BooleanOperations
    • Animations
      • PointMovingOnShapes
      • MovingAround
      • MovingAngle
      • MovingDots
      • MovingGroupToDestination
      • MovingFrameBox
      • RotationUpdater
      • PointWithTrace
    • Plotting
      • SinAndCosFunctionPlot
      • ArgMinExample
      • GraphAreaPlot
      • PolygonOnAxes
      • HeatDiagramPlot
  • 教程 And 指导
    • 快速使用
      • 概述
      • 新建Project
      • 制作动画
      • 解释
      • 正方形转换圆
      • 定位Mobject
      • 使用.animate语法进行动画处理
      • Transform与ReplacementTransform
    • 输出设置
      • Manim 输出文件夹
      • 章节
      • 命令行标志
    • Manim 的构建块
      • Mobjects
        • 创建和显示 mobjects
        • 放置 mobjects
        • 设置 mobject 的样式
        • Mobject 屏幕顺序
      • 动画
        • 制作方法动画
        • 动画运行时间
        • 创建自定义动画
        • 使用 mobject 的坐标
        • 将 mobject 转换为其他 mobject
      • 场景
  • 进阶指南
    • 配置
      • 命令行参数
        • 高级示例
        • 所有 CLI 标志的列表
      • ManimConfig 类
      • 配置文件
    • 深入了解 Manim 的内部结构
      • 介绍
      • 概述
      • Page
Powered by GitBook
On this page
  1. 教程 And 指导
  2. 输出设置

章节

除了影片输出文件之外,还可以使用章节。每个章节都会生成它自己的输出视频。两个部分之间的剪辑可以像这样设置:

def construct(self):
    # play the first animations...
    # you don't need a section in the very beginning as it gets created automatically
    self.next_section()
    # play more animations...
    self.next_section("this is an optional name that doesn't have to be unique")
    # play even more animations...
    self.next_section("this is a section without any animations, it will be removed")

其中两个剪辑之间的所有动画都连接到一个输出video 文件中。请注意,每个部分至少需要一个动画。例如,这不会创建输出视频:

def construct(self):
    self.next_section()
    # this section doesn't have any animations and will be removed
    # but no error will be thrown
    # feel free to tend your flock of empty sections if you so desire
    self.add(Circle())
    self.next_section()

解决此问题的一种方法是稍等片刻:

def construct(self):
    self.next_section()
    self.add(Circle())
    # now we wait 1sec and have an animation to satisfy the section
    self.wait()
    self.next_section()

对于每个部分要创建的视频,您必须将标志--save_sections添加到 Manim 调用中,如下所示:

manim --save_sections scene.py

如果您这样做,media文件夹将如下所示:

media
├── images
│   └── simple_scenes
└── videos
    └── simple_scenes
        └── 480p15
            ├── ElaborateSceneWithSections.mp4
            ├── partial_movie_files
            │   └── ElaborateSceneWithSections
            │       ├── 2201830969_104169243_1331664314.mp4
            │       ├── 2201830969_398514950_125983425.mp4
            │       ├── 2201830969_398514950_3447021159.mp4
            │       ├── 2201830969_398514950_4144009089.mp4
            │       ├── 2201830969_4218360830_1789939690.mp4
            │       ├── 3163782288_524160878_1793580042.mp4
            │       └── partial_movie_file_list.txt
            └── sections
                ├── ElaborateSceneWithSections_0000.mp4
                ├── ElaborateSceneWithSections_0001.mp4
                ├── ElaborateSceneWithSections_0002.mp4
                └── ElaborateSceneWithSections.json

如您所见,每个部分都会在sections目录中接收自己的输出视频。 此处的 JSON 文件包含每个部分的一些有用信息:

[
    {
        "name": "create square",
        "type": "default.normal",
        "video": "ElaborateSceneWithSections_0000.mp4",
        "codec_name": "h264",
        "width": 854,
        "height": 480,
        "avg_frame_rate": "15/1",
        "duration": "2.000000",
        "nb_frames": "30"
    },
    {
        "name": "transform to circle",
        "type": "default.normal",
        "video": "ElaborateSceneWithSections_0001.mp4",
        "codec_name": "h264",
        "width": 854,
        "height": 480,
        "avg_frame_rate": "15/1",
        "duration": "2.000000",
        "nb_frames": "30"
    },
    {
        "name": "fade out",
        "type": "default.normal",
        "video": "ElaborateSceneWithSections_0002.mp4",
        "codec_name": "h264",
        "width": 854,
        "height": 480,
        "avg_frame_rate": "15/1",
        "duration": "2.000000",
        "nb_frames": "30"
    }
]

这些数据可供第三方应用程序使用,例如演示系统或自动视频编辑工具。

你也可以跳过渲染属于某个部分的所有动画,如下所示:

def construct(self):
    self.next_section(skip_animations=True)
    # play some animations that shall be skipped...
    self.next_section()
    # play some animations that won't get skipped...
PreviousManim 输出文件夹Next命令行标志

Last updated 22 days ago