ManimCommunity / ManimCommunity/manim
Audio broken after silence in rerendered video
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## Description of bug / unexpected behavior
When having audio after silence, that audio is broken in rerendered videos.
Meanwhile the audio before the silence stays fine.
```py
class AudioTest(Scene):
def construct(self):
# audio before silence works fine
self.add_sound("audio.wav")
self.wait(5)
# silence
self.wait(3)
# audio after silence is broken after rerender
self.add_sound("audio.wav")
self.wait(5)
```
This bug seems to be caused by the caching system since the audio is fine
* for the initial render
* when disabling the caching
For example when looking at the following videos, you can see (hear) that when there is some silence at the start, the rerendered video doesn't have any audio. (first row)
Initial Render
Rerender
Rerender without caching
## Expected behavior
The audio after the silence should work in the rerendered video.
## How to reproduce the issue
Code for reproducing the problem
```py
from manim import *
import soundfile as sf
class InitialSilenceTest(Scene):
def construct(self) -> None:
# some silence
self.wait(3)
# playing a sound
self.add_sound("audio.wav")
self.wait(sf.info("audio.wav").duration)
class MiddleSilenceTest(Scene):
def construct(self) -> None:
self.add(Text("Middle Silence"))
self.add_sound("audio.wav")
self.wait(sf.info("audio.wav").duration)
self.wait(3)
self.add_sound("audio.wav")
self.wait(sf.info("audio.wav").duration)
class NoSilenceTest(Scene):
def construct(self) -> None:
self.add(Text("No Silence"))
self.add_sound("audio.wav")
self.wait(sf.info("audio.wav").duration)
```
I used these commands to videos above.
```console
manim main.py InitialSilenceTest MiddleSilenceTest NoSilenceTest
manim main.py InitialSilenceTest -o InitialSilenceTestRerendered
manim main.py MiddleSilenceTest -o MiddleSilenceTestRerendered
manim main.py NoSilenceTest -o NoSilenceTestRerendered
manim main.py InitialSilenceTest --disable_caching -o InitialSilenceTestNoCaching
manim main.py MiddleSilenceTest --disable_caching -o MiddleSilenceTestNoCaching
manim main.py NoSilenceTest --disable_caching -o NoSilenceTestNoCaching
```
## Additional media files
Audio
[audio.wav](https://github.com/user-attachments/files/28403222/audio.wav)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided InitialSilenceTest, MiddleSilenceTest, and NoSilenceTest commands, comparing the initial render, cached rerender, and --disable_caching results. Trace the caching and audio-rendering paths involved in rerendering; done means audio after silence is present and correct in cached rerenders as well as uncached renders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100