OpenCV VideoWriter在一个tim之后安静地停了下来

2024-10-06 14:33:29 发布

您现在位置:Python中文网/ 问答频道 /正文

在成功编写视频一段时间后,VideoWriter将静默地开始只创建空的视频文件。在

这是在树莓皮3上

开放式CV 2.4.9

以下脚本说明了该问题: 下面是一个独立的脚本来说明这个问题:

#!/usr/bin/pyton

import cv2
import time
import numpy
import subprocess

fourcc = cv2.cv.CV_FOURCC(*'MJPG')

allret = 0
f = numpy.ones((480,640,3), numpy.uint8)
h,w,c = f.shape
print h,w,c
counter = 0
while True:
    counter += 1
    print "Iteration: ", counter
    time.sleep(0.1)
    writer = cv2.VideoWriter("test.avi", fourcc, 5, (w,h))
    for i in xrange(20):
        writer.write(f)
    writer.release()
    writer = None
    ret = subprocess.call(["avprobe","test.avi"])
    allret += ret
    print "FAILURES:", allret
    if allret > 5:
        break

在大约800个成功的视频之后,我们只能得到糟糕的视频。重新启动脚本将重新启动该过程。在


Tags: testimportnumpy脚本视频timecountercv2