ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
24.35k stars 1.7k forks source link

[scene caching] partial movie file not found #472

Closed behackl closed 4 years ago

behackl commented 4 years ago

Here is another scene caching error: running the code

from manim import *

class TestZoom1(ZoomedScene):
        CONFIG = {
            "zoomed_camera_frame_starting_position": [0, 0, 0],
            "zoomed_display_corner": [0, 0, 0],
            "zoomed_display_height": config['frame_height'],
            "zoomed_display_width": config['frame_width'],
            "zoom_factor": 0.1,
        }
        def construct(self):
            self.activate_zooming(animate=True)
            d = Dot()
            self.add(d)

(one of our examples from the documentation) twice raises the following error:

[behackl@atreus playground]$ manim test.py TestZoom1 -m
[09/23/20 14:38:04] INFO     Animation 0 : Partial movie file written in {'/home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/partial_movie_files/TestZoom1/2818502609_1974117047_3316235269.mp4'}                       scene_file_writer.py:463
[09/23/20 14:38:05] INFO     Animation 1 : Partial movie file written in {'/home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/partial_movie_files/TestZoom1/1160423895_881011468_1267139589.mp4'}                        scene_file_writer.py:463
                    INFO                                                                                                                                                                                                                        scene_file_writer.py:635
                             File ready at /home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/TestZoom1.mp4                                                                                                                                      

                    INFO     Rendered TestZoom1                                                                                                                                                                                                             scene.py:129
                             Played 2 animations                                                                                                                                                                                                                        
[behackl@atreus playground]$ manim test.py TestZoom1 -m
[09/23/20 14:38:07] INFO     Animation 0 : Using cached data (hash : 2818502609_1974117047_3316235269)                                                                                                                                                      scene.py:823
[09/23/20 14:38:08] INFO     Animation 1 : Partial movie file written in {'/home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/partial_movie_files/TestZoom1/2818502609_1974117047_3316235269.mp4'}                       scene_file_writer.py:463
[concat @ 0x564241a313c0] Impossible to open 'file:/home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/partial_movie_files/TestZoom1/2796914319_881011468_1267139589.mp4'
/home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/partial_movie_files/TestZoom1/partial_movie_file_list.txt: No such file or directory
                    INFO                                                                                                                                                                                                                        scene_file_writer.py:635
                             File ready at /home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/TestZoom1.mp4                                                                                                                                      

Traceback (most recent call last):
  File "/home/behackl/Dokumente/git/etc/manim/manim/__main__.py", line 170, in main
    scene = SceneClass()
  File "/home/behackl/Dokumente/git/etc/manim/manim/scene/scene.py", line 93, in __init__
    self.file_writer.finish()
  File "/home/behackl/Dokumente/git/etc/manim/manim/scene/scene_file_writer.py", line 387, in finish
    self.combine_movie_files()
  File "/home/behackl/Dokumente/git/etc/manim/manim/scene/scene_file_writer.py", line 592, in combine_movie_files
    modify_atime(file_path)
  File "/home/behackl/Dokumente/git/etc/manim/manim/utils/file_ops.py", line 53, in modify_atime
    os.utime(file_path, times=(time.time(), os.path.getmtime(file_path)))
  File "/usr/lib/python3.8/genericpath.py", line 55, in getmtime
    return os.stat(filename).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/home/behackl/Dokumente/git/etc/manim/playground/media/videos/test/720p30/partial_movie_files/TestZoom1/2796914319_881011468_1267139589.mp4'

(I've noticed this from running make html && make clean && make html from docs.)

behackl commented 4 years ago

CC @ManimCommunity/scene-caching

cobordism commented 4 years ago

I can confirm this bug: https://github.com/ManimCommunity/manim/issues/460#issuecomment-697327133

huguesdevimeux commented 4 years ago

@behackl It's not a bug. Your scene won't generate any video, as there is no scene.playor scene.wait invocation. If you wonder why does it work sometimes, it's because manim opens a video file named with the name of the file containing the scene, no matter if the scene was supposed to produce something. So, what can happen is that manim takes an old generated video as it didn't get replaced by a new generated one.

Nevertheless, I think it should be change.

behackl commented 4 years ago

Your scene won't generate any video, as there is no scene.play or scene.wait invocation.

@huguesdevimeux self.activate_zooming(animate=True) seems to include a play call somewhere; the video included over at https://manimce.readthedocs.io/en/latest/examples/camera_settings.html is produced.

huguesdevimeux commented 4 years ago

@behackl You're right. I will investigate.

PS : First time I see the documentation quoted as a reference. Although I didn't contribute to it, I feel very proud :D

huguesdevimeux commented 4 years ago

Just to let you know, I found a potential fix. I will PR a soon as I can :D

behackl commented 4 years ago

PS : First time I see the documentation quoted as a reference. Although I didn't contribute to it, I feel very proud :D

It is pretty cool, I do have to admit. Even though there is still lots of work to do, its fun to see how it slowly becomes more and more useful! :-)

Thanks for investigating, I will certainly have a look at whatever you come up with. 👍

hugopy commented 4 years ago

I second this, also having this bug.

huguesdevimeux commented 4 years ago

This will take longer as I expected. This issue hides two : One related to how partial movie files are handled when some animations are skipped (in particular, when the first one is skipped), and one more serious that is that the hash produced by the second play call of scene.activate_zooming is non-consistent for some reason.

Sooo, not sure when I will fix this. But if you need to run these kind of stuff, using --disable_caching should work fine.

huguesdevimeux commented 4 years ago

should be fixed in #489