ffmpeg - 在 Python 上保存动画

标签 ffmpeg python

我正在尝试使用以下命令通过 Python 代码保存一个简单的动画女仆:

    anim = animation.FuncAnimation(fig, animate, init_func=init,
                                   frames = 100, interval = 20, blit = True)
    anim.save('basic_animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])

但是 Python 返回:
C:\Program Files\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\matplotlib\animation.py:971: UserWarning: MovieWriter ffmpeg unavailable
warnings.warn("MovieWriter %s unavailable" % writer)

Traceback (most recent call last):

File "<ipython-input-1-fd8a28a3225c>", line 1, in <module>
runfile('D:/Documents/Informatique/Spyder/test_anim2d.py', wdir='D:/Documents/Informatique/Spyder')

File "C:\Program Files\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
execfile(filename, namespace)

File "C:\Program Files\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/Documents/Informatique/Spyder/test_anim2d.py", line 34, in <module>
anim.save('basic_animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])

File "C:\Program Files\WinPython-64bit-3.6.1.0Qt5\python-3.6.1.amd64\lib\site-packages\matplotlib\animation.py", line 978, in save
raise ValueError("Cannot save animation: no writers are "

ValueError: Cannot save animation: no writers are available. Please install ffmpeg to save animations.

但是,我已经安装了ffmpeg,所以我不知道......

也许它在错误的目录中?我将它安装在 C:\Program Files\WinPython-64bit-3.6.1.0Qt5\scripts

谢谢!

最佳答案

ffmpeg 文件应该与你的 python 程序在同一个文件夹中。尝试将它复制到那里,看看是否有效。

关于ffmpeg - 在 Python 上保存动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53252983/

相关文章:

android - android 上 ffmpeg 命令行的问题

ffmpeg - 移除 QTKit 依赖

ffmpeg - 使用png与ffmpeg制作视频时如何保持透明度

node.js - ffmpeg:使用 NodeJS 从 stdin 渲染 webm

python - 删除 % 符号并将结果解析为整数

python - 如何在 Spark ALS 推荐器中增加矩阵因子?

python - 缺少一个参数时如何引发自己的错误?

python - 将平均值保存在文本文件中

audio - 在ffmpeg中同步音频和视频的结尾?

字符串格式化代码中的 Python TypeError