html - 使用 matplotlib 动画可视化 html 视频
问题描述
在我的笔记本中,我从 URL 获取一些数据,执行一些分析并进行一些绘图。
我还想使用FuncAnimation
of创建一个 html 动画matplotlib.animation
。所以在序言中我做
import matplotlib.animation as manim
plt.rcParams["animation.html"] = "html5"
%matplotlib inline
(别的东西...... def init()...
,def animate(i)...
)然后
anima = manim.FuncAnimation(fig,
animate,
init_func=init,
frames=len(ypos)-d0,
interval=200,
repeat=False,
blit=True)
为了形象化,我然后打电话给
FFMpegWriter = manim.writers['ffmpeg']
writer = FFMpegWriter(fps=15)
link = anima.to_html5_video()
from IPython.core.display import display, HTML
display(HTML(link))
因为我希望剪辑在笔记本中显示为整洁的 html 视频
虽然这在我的机器上运行良好,但在 Watson-Studio 上我收到以下错误:
RuntimeError: Requested MovieWriter (ffmpeg) not available
我已经检查了它ffmpeg
以 Python 包的形式提供
(!pip freeze --isolated | grep ffmpeg
给ffmpeg-python==0.2.0
)
问题是:我怎么知道matplotlib.animation.writers
在 中使用编解码器ffmpeg-python
?
非常感谢所有响应者和支持者
解决方案
我们目前没有在 Watson Studio on Cloud 中预安装 ffmpeg。您提到的包ffmpeg-python
只是一个 Python 包装器,但如果没有实际的 ffmpeg,它将无法工作。
您可以从 conda 安装 ffmpeg:
!conda install ffmpeg
获得笔记本所需的附加软件包的完整列表后,我建议创建一个自定义环境。然后您不必将安装命令放入实际的笔记本中。
自定义可能如下所示:
dependencies:
- ffmpeg=4.2.2
- pip
- pip:
- ffmpeg-python==0.2.0
推荐阅读
- asp.net-mvc - 检查模型的真实值
- python - 错误:字段大于字段限制 (131072)
- dji-sdk - UpdateJoystickValue 在 Windows-SDK 中不起作用
- ios - UITableView - 标题高度更改后重新定位单元格
- java - 没有找到 messages_XX.properties
- ruby-on-rails - 使用 Prawn 和 Carrierwave 上传 PDF 而不将文件保存在磁盘上
- c# - 如何在 C# 中编辑匿名动态列表
- wordpress-theming - yarn start localhost:3000 未加载
- java - 如何使用 Selenium WebDriver 或 JS 等待 iframe 内容加载?
- snakemake - 使用 Snakemake 时如何修复“文件名太长”错误