无法在python的videoWriter模块中使用opencv保存视频

问题描述 投票:1回答:1

下面是代码段。

fourcc = cv2.VideoWriter_fourcc(*)
out = cv2.VideoWriter('/Users\Dell\Documents\GitHub\capstoneproject\ProjectS\sample\example_03.mp4',fourcc, 20.0, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()


        # write the flipped frame
    out.write(frame)

    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

在上面,它无法保存视频。

python opencv image-processing video video-capture
1个回答
0
投票

我认为您忘记提供编解码器的类型。正确的代码应该是。

fourcc = cv2.VideoWriter_fourcc(*'type of codec')

编解码器的类型可以是mp4,XVID等

© www.soinside.com 2019 - 2024. All rights reserved.