【发布时间】:2020-04-15 07:33:50
【问题描述】:
我一直在尝试从文件夹中的所有静止图像创建视频。写入的文件大小为 0KB。我已经检查并且所有文件都被 glob.glob 部分正确检索(这就是注释的 print(filename) 行的内容)。我尝试了多个fourcc 选项,但没有一个有效。有没有人看到会导致这种情况的问题?这也在 Jupyter Notebook 中的 python 3 上运行。
fold_file = fold +'/*jpg' #fold is just the path to folder containing the images
img_array=[]
for filename in glob.glob(fold_file):
#print(filename)
img=cv2.imread(filename)
height, width, layer = img.shape
size = (width,height)
img_array.append(img)
out = cv2.VideoWriter('pleasework.avi',cv2.VideoWriter.fourcc('X','V','I','D') ,15,size)
for image in range(len(img_array)):
out.write(image)
cv2.destroyAllWindows()
out.release()
【问题讨论】:
-
请提供minimal reproducible example。顺便说一句,我建议您使用 pathlib 来满足您的所有路径操作需求。