feat(lib): allow to insert external videos as slides (#526)

* feat(lib): allow to insert external videos as slides

See https://github.com/jeertmans/manim-slides/discussions/520

* chore(lib): lint and changelog entry

* chore: fix PR #

fix

* fix: docs
This commit is contained in:
Jérome Eertmans
2025-01-29 18:17:45 +00:00
committed by GitHub
parent a2bd1ffb67
commit ccbe9d558c
6 changed files with 102 additions and 22 deletions

View File

@ -305,7 +305,7 @@ class BaseSlide:
:param skip_animations:
Exclude the next slide from the output.
If `manim` is used, this is also passed to `:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`,
If `manim` is used, this is also passed to :meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`,
which will avoid rendering the corresponding animations.
.. seealso::
@ -348,6 +348,11 @@ class BaseSlide:
``manim-slides convert --to=pptx``.
:param dedent_notes:
If set, apply :func:`textwrap.dedent` to notes.
:param pathlib.Path src:
An optional path to a video file to include as next slide.
The video will be copied into the output folder, but no rescaling
is applied.
:param kwargs:
Keyword arguments passed to
:meth:`Scene.next_section<manim.scene.scene.Scene.next_section>`,
@ -471,6 +476,18 @@ class BaseSlide:
self._current_slide += 1
if base_slide_config.src is not None:
self._slides.append(
PreSlideConfig.from_base_slide_config_and_animation_indices(
base_slide_config,
self._current_animation,
self._current_animation,
)
)
base_slide_config = BaseSlideConfig() # default
self._current_slide += 1
if self._skip_animations:
base_slide_config.skip_animations = True
@ -493,7 +510,7 @@ class BaseSlide:
)
)
def _save_slides(
def _save_slides( # noqa: C901
self,
use_cache: bool = True,
flush_cache: bool = False,
@ -540,7 +557,10 @@ class BaseSlide:
):
if pre_slide_config.skip_animations:
continue
slide_files = files[pre_slide_config.slides_slice]
if pre_slide_config.src:
slide_files = [pre_slide_config.src]
else:
slide_files = files[pre_slide_config.slides_slice]
try:
file = merge_basenames(slide_files)