writer¶
- class janim.render.writer.VideoWriter(built: BuiltTimeline, *, ctx: Context | None = None)¶
基类:
object将时间轴动画生成视频输出到文件中
可以直接调用
VideoWriter.writes(MyTimeline().build())进行输出主要流程在
write_all()中:首先调用 ffmpeg,这里用它生成视频(先输出到
_temp文件中)然后遍历动画的每一帧,进行渲染,并将像素数据传递给 ffmpeg
最后结束 ffmpeg 的调用,完成
_temp文件的输出将
_temp文件改名,删去_temp后缀,完成视频输出
- static writes(built: BuiltTimeline, file_path: str, *, quiet=False, use_pbo=True, hwaccel=False) None¶
- write_all(file_path: str, in_point: float | None = None, out_point: float | None = None, *, quiet=False, use_pbo=True, hwaccel=False, _keep_temp=False) None¶
将时间轴动画输出到文件中
指定
quiet=True,则不会输出前后的提示信息,但仍有进度条
- open_video_pipe(file_path: str, hwaccel: bool) None¶
- static ext_specific_flags(ffmpeg_bin: str, ext: str, hwaccel: bool) list[str]¶
针对不同的格式产生不同的 FFMPEG 参数
- static find_h264_encoder(ffmpeg_bin: str, hwaccel: bool) str¶
查找编码器,若
hwaccel=True则优先使用硬件编码器
- static test_encoder_usability(ffmpeg_bin: str, potential: str) bool¶
- static encoder_flags(encoder: str) list[str]¶
- static find_encoder_device() str | None¶
Return the first working VA-API render node, or None.
- close_video_pipe(_keep_temp: bool) None¶
- static handle_ffmpeg_not_found()¶
- class janim.render.writer.AudioWriter(built: BuiltTimeline)¶
基类:
object- static writes(built: BuiltTimeline, file_path: str, *, quiet=False) None¶
- write_all(file_path: str, *, quiet=False, _keep_temp=False) None¶
- open_audio_pipe(file_path: str) None¶
- close_audio_pipe(_keep_temp: bool) None¶
- janim.render.writer.merge_video_and_audio(ffmpeg_bin: str, video_path: str, audio_path: str, result_path: str, remove: bool = True, *, quiet: bool = False) None¶
- class janim.render.writer.SRTWriter¶
基类:
object- static writes(built: BuiltTimeline, file_path: str) None¶
- static t_to_srt_time(t: float)¶
将秒数转换为 SRT 时间格式:HH:MM:SS,mmm