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

asked 2019-10-17 09:02:52 -0600

ConstantineHB gravatar image

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
edit retag flag offensive close merge delete

Comments

1

compressing video frames is very expensive.

berak gravatar imageberak ( 2019-10-17 09:12:07 -0600 )edit

what you do mean?

ConstantineHB gravatar imageConstantineHB ( 2019-10-17 09:14:29 -0600 )edit