FFmpeg 和 Jupyter 笔记本
FFmpeg and Jupyter Notebooks
我在尝试 运行 this 在 Jupyter Notebook[=23= 中创建和显示动画的简单示例时遇到错误 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
可以找到它。您可以通过 运行 this 脚本轻松完成此操作:
# 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!')
希望对您有所帮助!
我在尝试 运行 this 在 Jupyter Notebook[=23= 中创建和显示动画的简单示例时遇到错误 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
可以找到它。您可以通过 运行 this 脚本轻松完成此操作:
# 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!')
希望对您有所帮助!