Ask Your Question

Revision history [back]

Why does simultaneously running two video writers produces a distorted output files?

I'm trying to produce 2 video files from a single RTP stream using OpenCV. The 2 files should each have 30 seconds length with the first 10 seconds of the 2nd file containing the last 10 seconds of the first file.

The first 20 seconds of the first file is written smoothly with no distortions but after second video writer is executed in parallel with the first video writer, the last 10 seconds started to be distorted and stuttery.

The first video writer will write the first video file then when it has reached the 20 second mark the second video writer will start to run simultaneously with the first one to write the second video file.

if frameCounter1 > (20 * frame_rate):

    has_frame, frame = vcap.read()

    if not has_frame:
        logging.error('Can\'t get frame (disconnected from camera stream)')
        sys.exit()

    vidWriter1.write(frame)
    frameCounter1 = frameCounter1 + 1

    vidWriter2.write(frame)
    frameCounter2 = frameCounter2 + 1