pipenv jupyter notebook matplotlib moviepy TypeError

问题描述

我在 pipenv 环境中安装了 jupyter notebook matplotlib 和 moviepy。当我从 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)

我收到此类型错误

~/.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,**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,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,withmask,audiofile,logger)
    211         logfile = None
    212     logger(message='Moviepy - Writing video %s\n' % filename)
--> 213     with FFMPEG_VideoWriter(filename,clip.size,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,size,logfile,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

好像和ffmpeg有关。我的系统上安装了 ffmpeg。有人知道出了什么问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...