Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] skip_animations causes ValueError: Cannot merge an empty list of files! #514

Closed
4 tasks done
Rapsssito opened this issue Jan 13, 2025 · 1 comment · Fixed by #516
Closed
4 tasks done

[BUG] skip_animations causes ValueError: Cannot merge an empty list of files! #514

Rapsssito opened this issue Jan 13, 2025 · 1 comment · Fixed by #516
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers lib Related to the library (a.k.a. module)

Comments

@Rapsssito
Copy link
Contributor

Rapsssito commented Jan 13, 2025

Terms

Describe the issue

Passing skip_animations=True to self.next_slide() raises the exception ValueError: Cannot merge an empty list of files! from manim_slides\slide\manim.py:136 > manim_slides\slide\base.py:526 > manim-slides\manim_slides\utils.py:68.

skip_animations=True is really useful for implementing long chained animations. I saw the PR #155, but maybe it breaks if all the animations from the slide are skipped?

Command

manim-slides render example.py MWE

Issue Type

Other

Python version

Python 3.12.7

Python environment

Manim Slides version: 5.2.0
Python executable: AppData\Local\Programs\Python\Python312\python.exe
Manim bindings:
        manim (version: 0.18.1)
        manimgl not found
Qt API: pyqt5 (version: 5.15.2)

What is your platform?

Windows

Other platform

No response

Manim Slides Python code

from manim import *

from manim_slides import *

class MWE(Slide):
    def construct(self):
        # Add a square and a circle
        square = Square()
        self.play(Create(square))
        self.next_slide(skip_animations=True)
        circle = Circle()
        self.play(Create(circle))

Relevant log output

No response

Screenshots

No response

Additional information

No response

Recommended fix or suggestions

An option could be adding a placeholder video instead of the slide if the slide does not contain any animations.

@Rapsssito Rapsssito added the bug Something isn't working label Jan 13, 2025
@jeertmans
Copy link
Owner

jeertmans commented Jan 13, 2025

Hi @Rapsssito, thanks for reporting this bug!

Indeed, #155 introduced support for skipping animations rendering, but it was meant to be used from the terminal with the -nx,y option, that renders animations from number x to number y, if I remember correctly. The issue arises when you skip rendering part of a slide, I think.

I don't think self.next_section(skip_animations=True) already existed at that time. But it could be a nice feature to support this! It could be as simple as storing a new skip_animations flag in

class PreSlideConfig(BaseSlideConfig):
"""Slide config to be used prior to rendering."""
start_animation: int
end_animation: int

and skip current iteration (with continue) in

for pre_slide_config in tqdm(
self._slides,
desc=f"Concatenating animation files to '{scene_files_folder}' and generating reversed animations",
leave=self._leave_progress_bar,
ascii=True if platform.system() == "Windows" else None,
disable=not self._show_progress_bar,
):
slide_files = files[pre_slide_config.slides_slice]
file = merge_basenames(slide_files)
dst_file = scene_files_folder / file.name
rev_file = scene_files_folder / f"{file.stem}_reversed{file.suffix}"
# We only concat animations if it was not present
if not use_cache or not dst_file.exists():
concatenate_video_files(slide_files, dst_file)
# We only reverse video if it was not present
if not use_cache or not rev_file.exists():
if skip_reversing:
rev_file = dst_file
else:
reverse_video_file(dst_file, rev_file)
slides.append(
SlideConfig.from_pre_slide_config_and_files(
pre_slide_config, dst_file, rev_file
)
)

if pre_slide_config.skip_animations is True.

I'll mark this as a good first issue, as I think it is relatively easy to solve.

@jeertmans jeertmans added enhancement New feature or request good first issue Good for newcomers lib Related to the library (a.k.a. module) labels Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers lib Related to the library (a.k.a. module)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants