我正在创建一个使用 MoviePy 模块的 Python 脚本,从较大的视频中获取剪辑并将它们连接在一起。
剪辑的时间在 CSV 文件中详细说明,如下所示;
0,10
11,19
15,20
34,42等
我所做的是逐行读取 CSV 文件,然后使用 Moviepy 中的 subclip 方法创建一个存储在剪辑列表中的剪辑,但是我得到一个 IndexError - 列表索引超出范围。
可能是什么问题(如果我不使用 subclip 方法和 CSV 文件中的值,代码可以正常工作)?
这是我的代码:
video= VideoFileClip('file')
clipsArray = []
import csv
with open('csv file', 'r') as file:
reader = csv.reader(file)
for row in reader:
startTime = row[0]
endTime = row[1]
clip = fullVideo.subclip(startTime, endTime)
clipsArray.append(clip)
Run Code Online (Sandbox Code Playgroud)
错误信息是:
文件“C:\Anaconda3\envs\py35\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py”,第 685 行,在运行文件 execfile(文件名,命名空间)中
文件“C:\Anaconda3\envs\py35\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py”,第 85 行,在 execfile exec(compile(open(filename, 'rb').read(),文件名、'exec')、命名空间)
File "C:/spyder2-py3/program.py", line 32, in Clip = fullVideo.subclip(start, end) # …