opencv VideoWriter是否有帧大小限制?

时间:2019-04-01 08:08:54

标签: python opencv video-capture

使用opencv将一堆图片保存到视频文件时,除非我调整图像大小,否则该文件不会打开: (Windows error - "This item is in a format we don't support. 0xc00d36b4")

我的代码如下:

import cv2
import os

input_path = "input_images_folder_path"
imgs_lst = os.listdir(r"C:\Users\...\input_path")
outvid_path = r"C:\Users\...\output.avi"

image0 = input_path +"\\"+ imgs_lst[0]
img0 = cv2.imread(image)    
size = (int(img0.shape[1]), int(img0.shape[0]))


fps = 12.0
is_color = True
fourcc = cv2.VideoWriter_fourcc(*"XVID")

vid = cv2.VideoWriter(outvid_path, fourcc, 10.0, size, True)

for i in range(0,50):# int(len(imgs_lst))):

    image = input_path +"\\"+ imgs_lst[i]
    img = cv2.imread(image,1)
    img = cv2.resize(img, size) #tried to comment this out... wont work either
    cv2.imshow("img", img)
    cv2.waitKey(1)

    vid.write(img)

vid.release()

如果我调整大小-

size = (int(img0.shape[1]/2), int(img0.shape[0]/2))
  • 一切正常。 我的问题是帧数是否有限制。我发现了有关输出文件大小限制的其他答案,但是关于单帧形状却一无所获。

(更改fps,格式也无效)

0 个答案:

没有答案