ManimCommunity / manim

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

GIF filename error : extra version mark in the filename #2562

Closed tcchhlegend closed 2 years ago

tcchhlegend commented 2 years ago

Description of bug / unexpected behavior

Expected behavior

While I was creating .gif images, the the filename was added with a version tag. This seems OK. But when other parts of Manim wants to access the image file, it uses the filename without the version tag, which causes errors.

ps: I looked into the source, and made some alterations. Now the issue can be resolved temporarily by my method, but I don't know what else could go wrong if I did this. What I have changed is as follows:

scene/scene_file_writer.py

603        # determine output path
604        movie_file_path = self.movie_file_path
605        if is_gif_format() and not config["output_file"]:
606            movie_file_path = self.gif_file_path
607        logger.info("Combining to Movie file.")

In line 606, I deleted the call of add_version_before_extension to self.gif_file_path. This drops the version mark when creating a .gif image. If you don't make this change, you will see an error.

How to reproduce the issue

Code for reproducing the problem SquareAndCircle.py ``` from manim import * class SquareAndCircle(Scene): def construct(self): circle = Circle() circle.set_fill(PINK, opacity=0.5) square = Square() square.set_fill(BLUE, opacity=0.5) self.play(Create(circle)) self.play(ClockwiseTransform(circle, square)) ``` The commandline calls for $ manim -pql --format=gif SquareAndCircle.py SquareAndCircle

Additional media files

Images/GIFs

Logs

Terminal output Manim Community v0.14.0 [02/20/22 22:14:03] INFO Animation 0 : Partial movie file written in 'C:\Users\ChenHaoHai\PycharmProjects\ChenIndustryHomePage\ChenIndustry\Unveil\backend\media\videos\SquareAndCircle\480p15\partial_movi scene_file_writer.py:514 e_files\SquareAndCircle\3163782288_2933097137_3768686611.mp4' INFO Animation 1 : Partial movie file written in 'C:\Users\ChenHaoHai\PycharmProjects\ChenIndustryHomePage\ChenIndustry\Unveil\backend\media\videos\SquareAndCircle\480p15\partial_movi scene_file_writer.py:514 e_files\SquareAndCircle\2201830969_2725689369_3768686611.mp4' INFO Combining to Movie file. scene_file_writer.py:608 [02/20/22 22:14:04] INFO scene_file_writer.py:729 File ready at 'C:\Users\ChenHaoHai\PycharmProjects\ChenIndustryHomePage\ChenIndustry\Unveil\backend\media\videos\SquareAndCircle\480p15\SquareAndCircle_ManimCE_v0.14.0.gif' INFO Rendered SquareAndCircle scene.py:237 Played 2 animations ┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐ │ │ │ c:\users\chenhaohai\pycharmprojects\chenindustryhomepage\venv\lib\site-packages\manim\cli\render │ │ \commands.py:139 in render │ │ │ │ 136 │ │ for SceneClass in scene_classes_from_file(file): │ │ 137 │ │ │ try: │ │ 138 │ │ │ │ scene = SceneClass() │ │ > 139 │ │ │ │ scene.render() │ │ 140 │ │ │ except Exception: │ │ 141 │ │ │ │ error_console.print_exception() │ │ 142 │ │ │ │ sys.exit(1) │ │ c:\users\chenhaohai\pycharmprojects\chenindustryhomepage\venv\lib\site-packages\manim\scene\scen │ │ e.py:246 in render │ │ │ │ 243 │ │ │ config["preview"] = True │ │ 244 │ │ │ │ 245 │ │ if config["preview"] or config["show_in_file_browser"]: │ │ > 246 │ │ │ open_media_file(self.renderer.file_writer) │ │ 247 │ │ │ 248 │ def setup(self): │ │ 249 │ │ """ │ │ │ │ c:\users\chenhaohai\pycharmprojects\chenindustryhomepage\venv\lib\site-packages\manim\utils\file │ │ _ops.py:200 in open_media_file │ │ │ │ 197 │ │ if config["show_in_file_browser"]: │ │ 198 │ │ │ open_file(file_path, True) │ │ 199 │ │ if config["preview"]: │ │ > 200 │ │ │ open_file(file_path, False) │ │ 201 │ │ │ │ │ 202 │ │ │ logger.info(f"Previewed File at: '{file_path}'") │ │ 203 │ │ │ │ c:\users\chenhaohai\pycharmprojects\chenindustryhomepage\venv\lib\site-packages\manim\utils\file │ │ _ops.py:170 in open_file │ │ │ │ 167 def open_file(file_path, in_browser=False): │ │ 168 │ current_os = platform.system() │ │ 169 │ if current_os == "Windows": │ │ > 170 │ │ os.startfile(file_path if not in_browser else os.path.dirname(file_path)) │ │ 171 │ else: │ │ 172 │ │ if current_os == "Linux": │ │ 173 │ │ │ commands = ["xdg-open"] │ └──────────────────────────────────────────────────────────────────────────────────────────────────┘ FileNotFoundError: [WinError 2] 系统找不到指定的文件。: 'C:\\Users\\ChenHaoHai\\PycharmProjects\\ChenIndustryHomePage\\ChenIndustry\\Unveil\\backend\\media\\videos\\SquareAndCircle\\480p15\\SquareAndCircle.gif'

System specifications

System Details - OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Win10 - RAM: 16GB - Python version (`python/py/python3 --version`): 3.9 - Installed modules (provide output from `pip list`): Package Version ------------------- ----------- asgiref 3.5.0 certifi 2021.10.8 charset-normalizer 2.0.12 click 8.0.4 click-default-group 1.2.2 cloup 0.7.1 colorama 0.4.4 colour 0.1.5 commonmark 0.9.1 decorator 5.1.1 Django 4.0.2 glcontext 2.3.4 idna 3.3 isosurfaces 0.1.0 manim 0.14.0 ManimPango 0.4.0.post2 mapbox-earcut 0.12.11 moderngl 5.6.4 moderngl-window 2.4.1 multipledispatch 0.6.0 networkx 2.6.3 numpy 1.22.2 Pillow 9.0.1 pip 21.1.2 pycairo 1.20.1 pydub 0.25.1 pyglet 1.5.21 Pygments 2.11.2 pyrr 0.10.3 requests 2.27.1 rich 11.2.0 scipy 1.8.0 screeninfo 0.6.7 setuptools 57.0.0 six 1.16.0 skia-pathops 0.7.2 sqlparse 0.4.2 srt 3.5.1 tqdm 4.62.3 tzdata 2021.5 urllib3 1.26.8 watchdog 2.1.6 wheel 0.36.2
LaTeX details + LaTeX distribution (e.g. TeX Live 2020): + Installed LaTeX packages:
FFMPEG Output of `ffmpeg -version`: ffmpeg version 5.0-full_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers built with gcc 11.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 57. 17.100 / 57. 17.100 libavcodec 59. 18.100 / 59. 18.100 libavformat 59. 16.100 / 59. 16.100 libavdevice 59. 4.100 / 59. 4.100 libavfilter 8. 24.100 / 8. 24.100 libswscale 6. 4.100 / 6. 4.100 libswresample 4. 3.100 / 4. 3.100 libpostproc 56. 3.100 / 56. 3.100

Additional comments

behackl commented 2 years ago

Hey! If I understand correctly, this bug has been fixed recently via #2528 on the current main branch, and will be released soon as part of v0.15.0.

ad-chaos commented 2 years ago

This was fixed in #2494 (previewing of gifs in general and also some MacOS specific problems) and other issues were fixed in #2528 (namely custom naming of gifs).