mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Write to movie
This commit is contained in:
parent
2726a4d60d
commit
23a9d40bd7
3 changed files with 48 additions and 45 deletions
|
|
@ -93,3 +93,8 @@ def using_opengl_renderer():
|
|||
|
||||
As of experimental, this fixture is deprecated and should not be using
|
||||
"""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def write_to_movie(config):
|
||||
config.write_to_movie = True
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ from ..utils.video_tester import video_comparison
|
|||
"SquareToCircleWithDefaultValues.json",
|
||||
"videos/simple_scenes/1080p60/SquareToCircle.mp4",
|
||||
)
|
||||
def test_basic_scene_with_default_values(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_basic_scene_with_default_values(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
sys.executable,
|
||||
|
|
@ -35,7 +37,7 @@ def test_basic_scene_with_default_values(tmp_path, manim_cfg_file, simple_scenes
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_resolution_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_resolution_flag(tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie):
|
||||
scene_name = "NoAnimations"
|
||||
# test different separators
|
||||
resolutions = [
|
||||
|
|
@ -76,7 +78,9 @@ def test_resolution_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
|||
"SquareToCircleWithlFlag.json",
|
||||
"videos/simple_scenes/480p15/SquareToCircle.mp4",
|
||||
)
|
||||
def test_basic_scene_l_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_basic_scene_l_flag(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
sys.executable,
|
||||
|
|
@ -97,7 +101,7 @@ def test_basic_scene_l_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
|||
"SceneWithMultipleCallsWithNFlag.json",
|
||||
"videos/simple_scenes/480p15/SceneWithMultipleCalls.mp4",
|
||||
)
|
||||
def test_n_flag(tmp_path, simple_scenes_path):
|
||||
def test_n_flag(tmp_path, simple_scenes_path, write_to_movie):
|
||||
scene_name = "SceneWithMultipleCalls"
|
||||
command = [
|
||||
sys.executable,
|
||||
|
|
@ -115,7 +119,9 @@ def test_n_flag(tmp_path, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_s_flag_no_animations(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_s_flag_no_animations(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
scene_name = "NoAnimations"
|
||||
command = [
|
||||
sys.executable,
|
||||
|
|
@ -139,7 +145,7 @@ def test_s_flag_no_animations(tmp_path, manim_cfg_file, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_s_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_s_flag(tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie):
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
sys.executable,
|
||||
|
|
@ -163,33 +169,7 @@ def test_s_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_s_flag_opengl_renderer(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
"manim",
|
||||
"-ql",
|
||||
"-s",
|
||||
"--renderer",
|
||||
"opengl",
|
||||
"--media_dir",
|
||||
str(tmp_path),
|
||||
str(simple_scenes_path),
|
||||
scene_name,
|
||||
]
|
||||
out, err, exit_code = capture(command)
|
||||
assert exit_code == 0, err
|
||||
|
||||
exists = (tmp_path / "videos").exists()
|
||||
assert not exists, "running manim with -s flag rendered a video"
|
||||
|
||||
is_empty = not any((tmp_path / "images" / "simple_scenes").iterdir())
|
||||
assert not is_empty, "running manim with -s flag did not render an image"
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_r_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_r_flag(tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie):
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
sys.executable,
|
||||
|
|
@ -217,7 +197,7 @@ def test_r_flag(tmp_path, manim_cfg_file, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_a_flag(tmp_path, manim_cfg_file, infallible_scenes_path):
|
||||
def test_a_flag(tmp_path, manim_cfg_file, infallible_scenes_path, write_to_movie):
|
||||
command = [
|
||||
sys.executable,
|
||||
"-m",
|
||||
|
|
@ -250,7 +230,7 @@ def test_a_flag(tmp_path, manim_cfg_file, infallible_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_custom_folders(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_custom_folders(tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie):
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
sys.executable,
|
||||
|
|
@ -275,7 +255,7 @@ def test_custom_folders(tmp_path, manim_cfg_file, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_custom_output_name_gif(tmp_path, simple_scenes_path):
|
||||
def test_custom_output_name_gif(tmp_path, simple_scenes_path, write_to_movie):
|
||||
scene_name = "SquareToCircle"
|
||||
custom_name = "custom_name"
|
||||
command = [
|
||||
|
|
@ -318,7 +298,7 @@ def test_custom_output_name_gif(tmp_path, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_custom_output_name_mp4(tmp_path, simple_scenes_path):
|
||||
def test_custom_output_name_mp4(tmp_path, simple_scenes_path, write_to_movie):
|
||||
scene_name = "SquareToCircle"
|
||||
custom_name = "custom_name"
|
||||
command = [
|
||||
|
|
@ -359,7 +339,7 @@ def test_custom_output_name_mp4(tmp_path, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_dash_as_filename(tmp_path):
|
||||
def test_dash_as_filename(tmp_path, write_to_movie):
|
||||
code = (
|
||||
"class Test(Scene):\n"
|
||||
" def construct(self):\n"
|
||||
|
|
@ -383,7 +363,9 @@ def test_dash_as_filename(tmp_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_gif_format_output(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_gif_format_output(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
"""Test only gif created with manim version in file name when --format gif is set"""
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
|
|
@ -415,7 +397,9 @@ def test_gif_format_output(tmp_path, manim_cfg_file, simple_scenes_path):
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_mp4_format_output(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_mp4_format_output(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
"""Test only mp4 created without manim version in file name when --format mp4 is set"""
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
|
|
@ -453,6 +437,7 @@ def test_videos_not_created_when_png_format_set(
|
|||
tmp_path,
|
||||
manim_cfg_file,
|
||||
simple_scenes_path,
|
||||
write_to_movie,
|
||||
):
|
||||
"""Test mp4 and gifs are not created when --format png is set"""
|
||||
scene_name = "SquareToCircle"
|
||||
|
|
@ -491,6 +476,7 @@ def test_images_are_created_when_png_format_set(
|
|||
tmp_path,
|
||||
manim_cfg_file,
|
||||
simple_scenes_path,
|
||||
write_to_movie,
|
||||
):
|
||||
"""Test images are created in media directory when --format png is set"""
|
||||
scene_name = "SquareToCircle"
|
||||
|
|
@ -518,6 +504,7 @@ def test_images_are_created_when_png_format_set_for_opengl(
|
|||
tmp_path,
|
||||
manim_cfg_file,
|
||||
simple_scenes_path,
|
||||
write_to_movie,
|
||||
):
|
||||
"""Test images are created in media directory when --format png is set for opengl"""
|
||||
scene_name = "SquareToCircle"
|
||||
|
|
@ -547,6 +534,7 @@ def test_images_are_zero_padded_when_zero_pad_set(
|
|||
tmp_path,
|
||||
manim_cfg_file,
|
||||
simple_scenes_path,
|
||||
write_to_movie,
|
||||
):
|
||||
"""Test images are zero padded when --format png and --zero_pad n are set"""
|
||||
scene_name = "SquareToCircle"
|
||||
|
|
@ -581,6 +569,7 @@ def test_images_are_zero_padded_when_zero_pad_set_for_opengl(
|
|||
tmp_path,
|
||||
manim_cfg_file,
|
||||
simple_scenes_path,
|
||||
write_to_movie,
|
||||
):
|
||||
"""Test images are zero padded when --format png and --zero_pad n are set with the opengl renderer"""
|
||||
scene_name = "SquareToCircle"
|
||||
|
|
@ -613,7 +602,9 @@ def test_images_are_zero_padded_when_zero_pad_set_for_opengl(
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_webm_format_output(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_webm_format_output(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
"""Test only webm created when --format webm is set"""
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
|
|
@ -651,6 +642,7 @@ def test_default_format_output_for_transparent_flag(
|
|||
tmp_path,
|
||||
manim_cfg_file,
|
||||
simple_scenes_path,
|
||||
write_to_movie,
|
||||
):
|
||||
"""Test .mov is created by default when transparent flag is set"""
|
||||
scene_name = "SquareToCircle"
|
||||
|
|
@ -684,7 +676,9 @@ def test_default_format_output_for_transparent_flag(
|
|||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_mov_can_be_set_as_output_format(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_mov_can_be_set_as_output_format(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
"""Test .mov is created by when set using --format mov arg"""
|
||||
scene_name = "SquareToCircle"
|
||||
command = [
|
||||
|
|
@ -722,7 +716,9 @@ def test_mov_can_be_set_as_output_format(tmp_path, manim_cfg_file, simple_scenes
|
|||
"InputFileViaCfg.json",
|
||||
"videos/simple_scenes/480p15/SquareToCircle.mp4",
|
||||
)
|
||||
def test_input_file_via_cfg(tmp_path, manim_cfg_file, simple_scenes_path):
|
||||
def test_input_file_via_cfg(
|
||||
tmp_path, manim_cfg_file, simple_scenes_path, write_to_movie
|
||||
):
|
||||
scene_name = "SquareToCircle"
|
||||
(tmp_path / "manim.cfg").write_text(
|
||||
f"""
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class StarScene(Scene):
|
|||
"transparent",
|
||||
[False, True],
|
||||
)
|
||||
def test_gif_writing(tmp_path, config, transparent):
|
||||
def test_gif_writing(tmp_path, config, write_to_movie, transparent):
|
||||
output_filename = f"gif_{'transparent' if transparent else 'opaque'}"
|
||||
config.media_dir = tmp_path
|
||||
config.quality = "low_quality"
|
||||
|
|
@ -88,7 +88,9 @@ def test_gif_writing(tmp_path, config, transparent):
|
|||
("webm", True, "vp9", "yuv420p"),
|
||||
],
|
||||
)
|
||||
def test_codecs(tmp_path, config, format, transparent, codec, pixel_format):
|
||||
def test_codecs(
|
||||
tmp_path, config, write_to_movie, format, transparent, codec, pixel_format
|
||||
):
|
||||
output_filename = f"codec_{format}_{'transparent' if transparent else 'opaque'}"
|
||||
config.media_dir = tmp_path
|
||||
config.quality = "low_quality"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue