gpt4 book ai didi

python - FFmpeg 和 Jupyter 笔记本

转载 作者:行者123 更新时间:2023-12-04 23:18:14 28 4
gpt4 key购买 nike

我收到错误 RuntimeError: Requested MovieWriter (ffmpeg) not available尝试运行时 this在 Jupyter Notebook 中创建和显示动画的简单示例。

---------------------------------------------------------------------------
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!')
希望能帮助到你!

关于python - FFmpeg 和 Jupyter 笔记本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72217039/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com