3

I have followed instructions to download ffmpeg and add the path according to Matplotlib-Animation "No MovieWriters Available" Although I can type version in both in command prompt and Bash on Windows console, beloved PyCharm warns me:

Requested MovieWriter (ffmpeg) not available

when I try to save the animation:

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

Do I have to add another path? Please, help me, I am really tired of this error.

fgh
  • 169
  • 1
  • 3
  • 15

3 Answers3

6

You can specify the ffmpeg path directly as follows:

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

or try on your cmd calling the ffmpeg to make sure the have properly defined its path in your env variables.

to get the path after making sure the path s properly defined, write in your cmd:

where ffmpeg 
Jesper - jtk.eth
  • 7,026
  • 11
  • 36
  • 63
Ahmed Hawary
  • 461
  • 4
  • 15
  • Indeed, your code doesn't make any errors which disable displaying the animation. However, as the saving is on the bottom of the script, after closing the figure window I see: `_tkinter.TclError: invalid command name "pyimage10"`, after `_tkinter.TclError: can't invoke "wm" command: application has been destroyed Exception in Tkinter callback` – fgh Mar 24 '19 at 11:37
  • 1) It takes some time for PyCharm to display the simulation. 2) The saved film is very, very speeded-up. 3) However, it is SAVED and I am building a mental golden monument for you! – fgh Mar 24 '19 at 11:56
  • Because the code will display the simulation after fully saving the animation. – Ahmed Hawary Mar 24 '19 at 11:58
  • Could add information about switching to your answer? I guess it would help other readers. – fgh Mar 24 '19 at 13:44
4

Windows 10: 1) open: Anaconda prompt 2) fire: conda install -c conda-forge ffmpeg 3) restart your environment

Worked for me.

contrl
  • 109
  • 1
  • 7
0

I suggest the following to show the simulation for a time t (for example 3000 ms here) then saving the animation before closing the animation because the problem in your code is to close the animation before creating saving so the tk backend fails to find the figure to draw inside of it. I suggest the following:

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()
Ahmed Hawary
  • 461
  • 4
  • 15