[英]FFmpeg and Jupyter Notebooks
尝试运行这个在Jupyter Notebook中创建和显示动画的简单示例时,出现错误RuntimeError: Requested MovieWriter (ffmpeg) not available
。
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-1-799d6a3690af> in <module>
8
9 # Define the meta data for the movie
---> 10 FFMpegWriter = manimation.writers['ffmpeg']
11 metadata = dict(title='Movie Test', artist='Matplotlib',
12 comment='a red circle following a blue sine wave')
/usr/local/lib/python3.8/dist-packages/matplotlib/animation.py in __getitem__(self, name)
164 if self.is_available(name):
165 return self._registered[name]
--> 166 raise RuntimeError(f"Requested MovieWriter ({name}) not available")
167
168
RuntimeError: Requested MovieWriter (ffmpeg) not available
运行!pip install ffmpeg
没有帮助,因为ffmpeg
已经安装,显然:
Requirement already satisfied: ffmpeg in /home/username/.local/lib/python3.8/site-packages
我怎样才能使这项工作?
我设法解决了这个问题,但是我花了很长时间才找到正确的解决方案,所以我会分享它以防它对某人有所帮助。 基本上,您需要下载最新的FFmpeg
静态构建并将其添加到PATH
,以便它可以被python
找到。 您可以通过运行以下脚本轻松完成此操作:
# Download a static FFmpeg build and add it to PATH.
exist = !which ffmpeg
if not exist:
!curl https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o ffmpeg.tar.xz \
&& tar -xf ffmpeg.tar.xz && rm ffmpeg.tar.xz
ffmdir = !find . -iname ffmpeg-*-static
path = %env PATH
path = path + ':' + ffmdir[0]
%env PATH $path
print('')
!which ffmpeg
print('Done!')
希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.