I installed jupyter notebook matplotlib and moviepy to my pipenv environment. When I run this code sample from https://zulko.github.io/moviepy/getting_started/working_with_matplotlib.html
import matplotlib.pyplot as plt
import numpy as np
from moviepy.editor import VideoClip
from moviepy.video.io.bindings import mplfig_to_npimage
x = np.linspace(-2, 2, 200)
duration = 2
fig, ax = plt.subplots()
def make_frame(t):
ax.clear()
ax.plot(x, np.sinc(x**2) + np.sin(x + 2*np.pi/duration * t), lw=3)
ax.set_ylim(-1.5, 2.5)
return mplfig_to_npimage(fig)
animation = VideoClip(make_frame, duration=duration)
animation.ipython_display(fps=20, loop=True, autoplay=True)
I get this TypeError:
~/.local/share/virtualenvs/Fourier_Analyses-WlUtXrFk/lib/python3.9/site-packages/moviepy/decorators.py in convert_masks_to_RGB(f, clip, *a, **k)
20 if clip.ismask:
21 clip = clip.to_RGB()
---> 22 return f(clip, *a, **k)
23
24 @decorator.decorator
~/.local/share/virtualenvs/Fourier_Analyses-WlUtXrFk/lib/python3.9/site-packages/moviepy/video/VideoClip.py in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, rewrite_audio, remove_temp, write_logfile, verbose, threads, ffmpeg_params, logger)
298 logger=logger)
299
--> 300 ffmpeg_write_video(self, filename, fps, codec,
301 bitrate=bitrate,
302 preset=preset,
~/.local/share/virtualenvs/Fourier_Analyses-WlUtXrFk/lib/python3.9/site-packages/moviepy/video/io/ffmpeg_writer.py in ffmpeg_write_video(clip, filename, fps, codec, bitrate, preset, withmask, write_logfile, audiofile, verbose, threads, ffmpeg_params, logger)
211 logfile = None
212 logger(message='Moviepy - Writing video %s\n' % filename)
--> 213 with FFMPEG_VideoWriter(filename, clip.size, fps, codec = codec,
214 preset=preset, bitrate=bitrate, logfile=logfile,
215 audiofile=audiofile, threads=threads,
~/.local/share/virtualenvs/Fourier_Analyses-WlUtXrFk/lib/python3.9/site-packages/moviepy/video/io/ffmpeg_writer.py in __init__(self, filename, size, fps, codec, audiofile, preset, bitrate, withmask, logfile, threads, ffmpeg_params)
86 '-s', '%dx%d' % (size[0], size[1]),
87 '-pix_fmt', 'rgba' if withmask else 'rgb24',
---> 88 '-r', '%.02f' % fps,
89 '-an', '-i', '-'
90 ]
TypeError: must be real number, not NoneType
It seems to be related to ffmpeg. I have ffmpeg installed on my system. Does anybody have an idea what is wrong?