OpenCV VideoWriter silently stops after a time

406 views Asked by At

After writing videos successfully for awhile, VideoWriter will silently start creating only empty video files.

This is on a Raspberry PI 3

OpenCV 2.4.9

The following script illustrates the issue: Here's a standalone script that illustrates the issue:

#!/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

After about 800 or so successful videos we then only get bad videos. Restarting the scripts starts the process over.

0

There are 0 answers