Skip to content

feat(lib): add audio to partial movie files and section videos#3763

Open
jeertmans wants to merge 2 commits into
ManimCommunity:mainfrom
jeertmans:split_audio
Open

feat(lib): add audio to partial movie files and section videos#3763
jeertmans wants to merge 2 commits into
ManimCommunity:mainfrom
jeertmans:split_audio

Conversation

@jeertmans
Copy link
Copy Markdown
Contributor

@jeertmans jeertmans commented May 16, 2024

Overview: What does this pull request change?

With this PR, audio is added when writing partial movies. Before, it was only added at the end, so partial movie files and section videos did not contain audio.

Motivation and Explanation: Why and how do your changes improve the library?

My main motivation is jeertmans/manim-slides#375, in line with what I mentioned in #3501 (@behackl).

Further Information and Comments

Minimal working example:

from pathlib import Path
from manim import Scene, Create, Circle, Dot, GrowFromCenter

class AudioPartialScene(Scene):
    def construct(self):
        click_path = (
            Path(__file__).parent
            / "docs"
            / "source"
            / "_static"
            / "click.wav"
        )
        self.add_sound(click_path)
        self.play(Create(Circle()))
        self.wait(0.5)
        self.next_section()
        self.add_sound(click_path)
        d = Dot()
        self.play(GrowFromCenter(d), run_time=0.25)
        self.wait(0.5)
        self.add_sound(click_path)
        d.set_color("red")
        self.wait(0.5)

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly

@jeertmans
Copy link
Copy Markdown
Contributor Author

Note: the commit history looks very weird, even though I rebased onto your main branch...

if ptype == "video":
packet.stream = output_video_stream
elif ptype == "audio":
packet.stream = output_audio_stream

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable

Local variable 'output_audio_stream' may be used before it is initialized.
@chopan050 chopan050 changed the title feat(lib): feat(lib): add audio to partial movie files and section videos May 16, 2024
@chopan050
Copy link
Copy Markdown
Member

Hello, and thanks for your contribution!

The current PR is still in draft for the following reasons:

Is it still a draft? (asking because of the failing tests) If so, please mark it as a draft, thanks!

@jeertmans
Copy link
Copy Markdown
Contributor Author

Hello, and thanks for your contribution!

The current PR is still in draft for the following reasons:

Is it still a draft? (asking because of the failing tests) If so, please mark it as a draft, thanks!

Hello! Yes it is, I forgot to tick the « draft » box :)

@jeertmans jeertmans marked this pull request as draft May 17, 2024 08:44
@jeertmans jeertmans marked this pull request as ready for review May 17, 2024 11:57
@jeertmans
Copy link
Copy Markdown
Contributor Author

jeertmans commented May 17, 2024

@chopan050 This is now ready for reviewing! I haven't added any test yet, but not sure where / how to correctly test this. I have looked at the current test suite, and we don't have many tests for sound nor partial movie files.

Edit: it seems that adding audio alters the duration of the media (could be logic) but also the frame rate?? So some tests (based on video metadata) are failing...

@jeertmans jeertmans marked this pull request as ready for review May 11, 2026 15:24
@jeertmans
Copy link
Copy Markdown
Contributor Author

Hi @chopan050 / @behackl, I finally had some time to work again on this, and think I have a good working prototype :-)

@jeertmans
Copy link
Copy Markdown
Contributor Author

Can't reproduce the failing tests locally: they all pass on my machine (Ubuntu 24.04.4)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

3 participants