ManimCommunity / ManimCommunity/manim

Sound timing is off when a previous section has been skipped

Open
#2,449 1 comment 0 reactions 0 assignees View on GitHub
issue:bug
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

When a section is skipped, with the command "self.next_section(skip_animations=True)", any sound that is added on a subsequent (non-skipped) section, will start later than it should.

I believe that this occurs because in the play() method of the renderer (either cairo or opengl), scene time is added up even for skipped animations (see cairo_render.py, line 61, opengl_renderer.py, line 418, in Manim v 0.14.0). Changing this fixes the issue (at least when using cairo), but I don't know if it messes up anything else.

## Expected behavior

Sound should begin at the point that it appears in the code, even if animations of some previous section have been skipped.

## How to reproduce the issue

Code for reproducing the problem

```py
from manim import *

class Main(Scene):
def construct(self):
self.next_section(skip_animations=True)
self.play(Create(Circle()),run_time=2)
self.wait(2)

self.next_section(skip_animations=False)
self.play(Create(Square()))
self.add_sound("click.wav")
self.wait(1)
```

## Additional media files

Images/GIFs

## Logs
Terminal output

```
Manim Community v0.14.0

[01/08/22 23:53:05] DEBUG Skipping animation 0 cairo_renderer.py:59
DEBUG List of the first few animation hashes of the scene: [None] cairo_renderer.py:83
DEBUG Animation with empty mobject animation.py:165
DEBUG Skipping animation 1 cairo_renderer.py:59
DEBUG List of the first few animation hashes of the scene: [None, None] cairo_renderer.py:83
INFO Caching disabled. cairo_renderer.py:64
DEBUG List of the first few animation hashes of the scene: [None, None, cairo_renderer.py:83
'uncached_00002']
INFO Animation 2 : Partial movie file written in 'C:\Users\Alex\manim scene_file_writer.py:514
projects\media\videos\test2\480p15\partial_movie_files\Main\uncac
hed_00002.mp4'
DEBUG Animation with empty mobject animation.py:165
INFO Caching disabled. cairo_renderer.py:64
DEBUG List of the first few animation hashes of the scene: [None, None, cairo_renderer.py:83
'uncached_00002', 'uncached_00003']
INFO Animation 3 : Partial movie file written in 'C:\Users\Alex\manim scene_file_writer.py:514
projects\media\videos\test2\480p15\partial_movie_files\Main\uncac
hed_00003.mp4'
INFO Combining to Movie file. scene_file_writer.py:608
DEBUG Partial movie files to combine (2 files): scene_file_writer.py:551
['C:\\Users\\Alex\\manim projects\\media\\videos\\test2\\480p15\\
partial_movie_files\\Main\\uncached_00002.mp4',
'C:\\Users\\Alex\\manim projects\\media\\videos\\test2\\480p15\\p
artial_movie_files\\Main\\uncached_00003.mp4']
[01/08/22 23:53:06] INFO scene_file_writer.py:729
File ready at 'C:\Users\Alex\manim
projects\media\videos\test2\480p15\Main.mp4'

INFO Rendered Main scene.py:237
Played 4 animations
INFO Previewed File at: 'C:\Users\Alex\manim file_ops.py:202
projects\media\videos\test2\480p15\Main.mp4'
```

## System specifications

System Details

```
- OS: Windows 10 Home build 19042.1415
- RAM: 8 GB
- Python version: 3.9.9
- Installed modules (provide output from `pip list`):
backcall 0.2.0
certifi 2021.10.8
charset-normalizer 2.0.9
click 8.0.3
click-default-group 1.2.2
cloup 0.7.1
colorama 0.4.4
colour 0.1.5
commonmark 0.9.1
cycler 0.11.0
decorator 5.1.0
fonttools 4.28.5
glcontext 2.3.4
idna 3.3
ipython 7.30.1
isosurfaces 0.1.0
jedi 0.18.1
kiwisolver 1.3.2
manim 0.14.0
ManimPango 0.4.0.post0
mapbox-earcut 0.12.11
matplotlib 3.5.1
matplotlib-inline 0.1.3
moderngl 5.6.4
moderngl-window 2.4.1
mpmath 1.2.1
multipledispatch 0.6.0
networkx 2.6.3
numpy 1.21.5
packaging 21.3
parso 0.8.3
pickleshare 0.7.5
Pillow 8.4.0
pip 21.3.1
prompt-toolkit 3.0.24
pycairo 1.20.1
pydub 0.25.1
pyglet 1.5.21
Pygments 2.10.0
PyOpenGL 3.1.5
pyparsing 3.0.6
pyreadline 2.1
pyrr 0.10.3
python-dateutil 2.8.2
PyYAML 6.0
requests 2.26.0
rich 10.16.1
scipy 1.7.3
screeninfo 0.6.7
setuptools 58.1.0
six 1.16.0
skia-pathops 0.7.2
srt 3.5.0
sympy 1.9
tqdm 4.62.3
traitlets 5.1.1
urllib3 1.26.7
validators 0.18.2
watchdog 2.1.6
wcwidth 0.2.5
```

LaTeX details

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:

FFMPEG

Output of `ffmpeg -version`:

```
ffmpeg version 2021-12-23-git-60ead5cd68-full_build-www.gyan.dev
```

## Additional comments

Contributor guide

Open the contributing guide

Research direction

Start in cairo_renderer.py around line 61 and opengl_renderer.py around line 418, tracing the play() method and how skipped animations affect scene time. Reproduce the issue with the provided Main scene and confirm that the sound added after the skipped section starts at the code position for both renderers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc, computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.