3b1b / manim

Animation engine for explanatory math videos
MIT License
61.93k stars 5.77k forks source link

python extract_scene.py example_scenes.py SquareToCircle -pl cant srun #299

Closed jiangbo0216 closed 5 years ago

jiangbo0216 commented 5 years ago

met a problem at first step, I at first thought this may be the enviroment problem. but I finally cant fix it . and this might not be friendly to newer. what I met as flow:


Traceback (most recent call last):
  File "extract_scene.py", line 289, in main
    handle_scene(SceneClass(**scene_kwargs), **config)
  File "D:\pycairo\py\manim\scene\scene.py", line 71, in __init__
    self.construct(*self.construct_args)
  File "D:\pycairo\py\manim\example_scenes.py", line 22, in construct
    self.play(ShowCreation(square))
  File "D:\***\py\manim\scene\scene.py", line 481, in play
    self.add_frames(self.get_frame())
  File "D:\pycairo\py\manim\scene\scene.py", line 553, in add_frames
    self.writing_process.stdin.write(frame.tostring())
BrokenPipeError: [Errno 32] Broken pipe

my enviroment is win10 anaconda --py37 lib I install is

eulertour commented 5 years ago

Something seems to be wrong with your version of ffmpeg. Maybe reinstalling will help? It might also be informative to run ffmpeg -y -f rawvideo -s 854x480 -pix_fmt rgba -r 15 -i - -an -loglevel error -vcodec libx264 -pix_fmt yuv420p <your media directory here>/animations/example_scenes/480p15/SquareToCircleTemp.mp4 from the command line, since this is exactly the command manim is attempting to write to when it gets the error.

jiangbo0216 commented 5 years ago

oh,thank for the hint, I found my mistake. I pip install ffmpeg that is so wrong .I am sorry and thank you . I download the zip in ffmpeg and latex and sox, so far. it run well !

lihonghui123 commented 5 years ago

C:\Users\00lim\Downloads\manim-master\manim-master>python extract_scene.py -p example_scenes.py SquareToCircle Traceback (most recent call last): File "extract_scene.py", line 299, in main() File "extract_scene.py", line 259, in main module = get_module(config["file"]) File "extract_scene.py", line 254, in get_module return importlib.import_module(module_name) File "C:\Users\00lim\Downloads\python3.7\lib\importlib__init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\00lim\Downloads\manim-master\manim-master\example_scenes.py", line 3, in from big_ol_pile_of_manim_imports import File "C:\Users\00lim\Downloads\manim-master\manim-master\big_ol_pile_of_manim_imports.py", line 80, in from scene.scene_from_video import File "C:\Users\00lim\Downloads\manim-master\manim-master\scene\scene_from_video.py", line 4, in import cv2 File "C:\Users\00lim\Downloads\python3.7\lib\site-packages\cv2\init__.py", line 3, in from .cv2 import * ImportError: DLL load failed: 找不到指定的模块。

C:\Users\00lim\Downloads\manim-master\manim-master>

lihonghui123 commented 5 years ago

thank you

mylovezhuo commented 5 years ago

My envirnoment is py37 on windows 7, the version of ffmpeg is 1.18.0, and I run pip install -r requirements.txt, all is ok. But error occurs when running the example!

C:\Program Files\Git\manim>python extract_scene.py -w example_scenes.py Square ToCircle Traceback (most recent call last): File "extract_scene.py", line 15, in from scene.scene import Scene File "C:\Program Files\Git\manim\scene\scene.py", line 22, in from camera.camera import Camera File "C:\Program Files\Git\manim\camera\camera.py", line 9, in from scipy.spatial.distance import pdist File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\sit e-packages\scipy\spatial__init.py", line 94, in from .kdtree import * File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\sit e-packages\scipy\spatial\kdtree.py", line 8, in import scipy.sparse File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\sit e-packages\scipy\sparse\init__.py", line 229, in from .csr import * File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\sit e-packages\scipy\sparse\csr.py", line 15, in from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \ ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。

C:\Program Files\Git\manim>

xorange commented 5 years ago

I had the same problem.

I added a debug print in scene_file_write.py:

diff --git a/manimlib/scene/scene_file_writer.py b/manimlib/scene/scene_file_writer.py
index a6aaa72..46b4b12 100644
--- a/manimlib/scene/scene_file_writer.py
+++ b/manimlib/scene/scene_file_writer.py
@@ -241,6 +241,7 @@ class SceneFileWriter(object):
                 command += [STREAMING_PROTOCOL + '://' + STREAMING_IP + ':' + STREAMING_PORT]
         else:
             command += [temp_file_path]
+        print('### DEBUG', command)
         self.writing_process = subprocess.Popen(command, stdin=subprocess.PIPE)

     def close_movie_pipe(self):

Then run the tutorial: (and got error 'Unknown encoder 'libx264'')

 $ python3 -m manim example_scenes.py SquareToCircle -pl
Media will be stored in media/. You can change this behavior by writing a different directory to media_dir.txt.
/anaconda3/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)
### DEBUG ['ffmpeg', '-y', '-f', 'rawvideo', '-s', '854x480', '-pix_fmt', 'rgba', '-r', '15', '-i', '-', '-c:v', 'h264_nvenc', '-an', '-loglevel', 'error', '-vcodec', 'libx264', '-pix_fmt', 'yuv420p', '/Users/orange-22/Documents/1-技术积累/manim/media/videos/example_scenes/480p15/partial_movie_files/SquareToCircle/00000_temp.mp4']
Animation 0: ShowCreationSquare:   0%|                                                                                                                     | 0/15 [00:00<?, ?it/s]Unknown encoder 'libx264'

Traceback (most recent call last):
  File "/Users/orange-22/Documents/1-技术积累/manim/manimlib/extract_scene.py", line 153, in main
    scene = SceneClass(**scene_kwargs)
  File "/Users/orange-22/Documents/1-技术积累/manim/manimlib/scene/scene.py", line 52, in __init__
    self.construct()
  File "example_scenes.py", line 81, in construct
    self.play(ShowCreation(square))
  File "/Users/orange-22/Documents/1-技术积累/manim/manimlib/scene/scene.py", line 404, in wrapper
    func(self, *args, **kwargs)
  File "/Users/orange-22/Documents/1-技术积累/manim/manimlib/scene/scene.py", line 461, in play
    self.progress_through_animations(animations)
  File "/Users/orange-22/Documents/1-技术积累/manim/manimlib/scene/scene.py", line 437, in progress_through_animations
    self.add_frames(self.get_frame())
  File "/Users/orange-22/Documents/1-技术积累/manim/manimlib/scene/scene.py", line 538, in add_frames
    self.file_writer.write_frame(frame)
  File "/Users/orange-22/Documents/1-技术积累/manim/manimlib/scene/scene_file_writer.py", line 171, in write_frame
    self.writing_process.stdin.write(frame.tostring())
BrokenPipeError: [Errno 32] Broken pipe

I tried to run the raw command with log level trace and got this:

 $ ffmpeg -y -f rawvideo -s 854x480 -pix_fmt rgba -r 15 -c:v h264_nvenc -an -loglevel trace -vcodec libx264 -pix_fmt yuv420p -i - media/videos/example_scenes/480p15/partial_movie_files/SquareToCircle/00000_temp.mp4
ffmpeg version N-81494-ga0a5707 Copyright (c) 2000-2016 the FFmpeg developers
  built with Apple LLVM version 7.0.2 (clang-700.1.81)
  configuration: 
  libavutil      55. 29.100 / 55. 29.100
  libavcodec     57. 54.101 / 57. 54.101
  libavformat    57. 48.101 / 57. 48.101
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 58.100 /  6. 58.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
Splitting the commandline.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'rawvideo'.
Reading option '-s' ... matched as option 's' (set frame size (WxH or abbreviation)) with argument '854x480'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'rgba'.
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '15'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'h264_nvenc'.
Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'libx264'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option '-i' ... matched as input file with argument '-'.
Reading option 'media/videos/example_scenes/480p15/partial_movie_files/SquareToCircle/00000_temp.mp4' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option y (overwrite output files) with argument 1.
Applying option loglevel (set logging level) with argument trace.
Successfully parsed a group of options.
Parsing a group of options: input file -.
Applying option f (force format) with argument rawvideo.
Applying option s (set frame size (WxH or abbreviation)) with argument 854x480.
Applying option pix_fmt (set pixel format) with argument rgba.
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 15.
Applying option c:v (codec name) with argument h264_nvenc.
Applying option an (disable audio) with argument 1.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument libx264.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Successfully parsed a group of options.
Opening an input file: -.
Unknown decoder 'libx264'

My ffmpeg are installed from Homebrew:

 $ brew info ffmpeg
ffmpeg: stable 4.1.1 (bottled), HEAD
Play, record, convert, and stream audio and video
https://ffmpeg.org/
/usr/local/Cellar/ffmpeg/4.1.1 (282 files, 58.6MB)
  Poured from bottle on 2019-03-20 at 21:56:47
From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/ffmpeg.rb
==> Dependencies
Build: nasm ✘, pkg-config ✔, texi2html ✘
Required: aom ✔, fontconfig ✔, freetype ✔, frei0r ✔, gnutls ✔, lame ✔, libass ✔, libbluray ✔, libsoxr ✔, libvorbis ✔, libvpx ✔, opencore-amr ✔, openjpeg ✔, opus ✔, rtmpdump ✔, rubberband ✔, sdl2 ✔, snappy ✔, speex ✔, tesseract ✔, theora ✔, x264 ✔, x265 ✔, xvid ✔, xz ✔
==> Options
--HEAD
    Install HEAD version

I'm not familiar with ffmpeg's arguments and compile options, and could not spot any problems. Is there someone that could help?

xorange commented 5 years ago

My ffmpeg are installed from Homebrew:

 $ brew info ffmpeg
ffmpeg: stable 4.1.1 (bottled), HEAD
Play, record, convert, and stream audio and video
https://ffmpeg.org/
/usr/local/Cellar/ffmpeg/4.1.1 (282 files, 58.6MB)
  Poured from bottle on 2019-03-20 at 21:56:47
From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/ffmpeg.rb
==> Dependencies
Build: nasm ✘, pkg-config ✔, texi2html ✘
Required: aom ✔, fontconfig ✔, freetype ✔, frei0r ✔, gnutls ✔, lame ✔, libass ✔, libbluray ✔, libsoxr ✔, libvorbis ✔, libvpx ✔, opencore-amr ✔, openjpeg ✔, opus ✔, rtmpdump ✔, rubberband ✔, sdl2 ✔, snappy ✔, speex ✔, tesseract ✔, theora ✔, x264 ✔, x265 ✔, xvid ✔, xz ✔
==> Options
--HEAD
  Install HEAD version

I'm not familiar with ffmpeg's arguments and compile options, and could not spot any problems. Is there someone that could help?

Update:

I abandoned homebrew's FFmpeg and used the MacOS prebuilt binary, which solved the problem.

So I'm guessing the homebrew version of FFmpeg lacks some compile option for codec libx264. Wish there's a way to configure it and rebuild via homebrew. But anyway now I'm happy with the prebuilt one.

Thanks guys.