MovieWriter(ffmpeg)不可用PyCharm(Windows)

时间:2019-03-24 10:49:47

标签: python-3.x windows matplotlib animation ffmpeg

我已按照说明下载ffmpeg,并根据以下说明添加了路径 Matplotlib-Animation "No MovieWriters Available" 尽管我可以在命令提示符和Windows控制台的Bash中都输入version,但是心爱的PyCharm会警告我:

Requested MovieWriter (ffmpeg) not available

当我尝试保存动画时:

ani = anim.FuncAnimation(fig, animate, frames = 14, init_func = init, interval = 500, repeat = False)
plt.show()
ani.save("Inno.mp4", writer=writer)

我是否必须添加其他路径?请帮帮我,我真的对这个错误感到厌倦。

3 个答案:

答案 0 :(得分:3)

Windows 10: 1)打开:Anaconda提示 2)火:conda install -c conda-forge ffmpeg 3)重新启动环境

为我工作。

答案 1 :(得分:2)

您可以直接指定ffmpeg路径,如下所示:

plt.rcParams['animation.ffmpeg_path'] = 'ffmpeg path on your machine' (e.g.: "C:\FFmpeg\bin\ffmpeg.exe")

或尝试在您的cmd上调用ffmpeg,以确保已在env变量中正确定义了其路径。

要在确保正确定义路径之后获取路径,请在您的cmd中输入:

where ffmpeg 

答案 2 :(得分:0)

我建议以下内容显示模拟时间t(例如此处为3000 ms),然后在关闭动画之前保存动画,因为代码中的问题是在创建保存之前关闭动画,因此tk后端无法找到要在其中绘制的图形。我建议以下内容:

def close():
    animation.save("Inno.mp4", writer='ffmpeg')
    plt.close()


timer = fig.canvas.new_timer(interval = 1000) 
timer.add_callback(close)

plt.show(block=False)
timer.start()
plt.show()