“'float' 对象不能解释为整数”moviepy 错误

"'float' object cannot be interpreted as an integer" moviepy error

我正在使用 MoviePy 库自动连接文件夹中的视频。但是当我 运行 这个代码时:

import os
from moviepy.editor import *
clips = ['clips/clip-1.mp4', 'clips/clip-2.mp4']
video = concatenate_videoclips(clips, method='compose')

我在我的终端中收到这条消息

Traceback (most recent call last):
  File "c:/video machine/test.py", line 7, in <module>
    clips.append(VideoFileClip('clips/' + filename))
  File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 82, in __init__
    nbytes = audio_nbytes)
  File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 63, in __init__
    buffersize=buffersize)
  File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\readers.py", line 70, in __init__
    self.buffer_around(1)
  File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\readers.py", line 234, in buffer_around
    self.buffer =  self.read_chunk(self.buffersize)
  File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\readers.py", line 123, in read_chunk
    self.nchannels))
TypeError: 'float' object cannot be interpreted as an integer

这是一个错误,但在最新版本中已修复。详细可以看TypeError: 'float' object cannot be interpreted as an integer

您可以通过运行

获取最新版本的moviepy
pip3 install moviepy --upgrade