I want to write a program that monitors and tracks objects in 2 different videos using openCV in python (cv2).
I would like to Merge the two videos into 1 video then run a program on that video to track objects.
Could someone please show and explain the instructions behind merging them?
My code here doesn't Work. It launches video 2 after the first frame of video 1
import cv2
capture = cv2.VideoCapture('p1a_tetris_1.mp4') #tell open cv to use the following video file as input
while capture.isOpened():
        ret, frame = capture.read() #capture each frame from the video . 
                                #ret is a boolean to indicate if the 
        if ret == True :    
            grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # apply gray frame to current frame
            cv2.imshow('video Part 1', grayFrame) # shows video in grascale 
        else : 
            capture = cv2.VideoCapture('p1a_tetris_2.mp4')
            while capture.isOpened():
                try:      
                    ret, frame = capture.read()
                    print(ret)
                    if ret == True :    
                        grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # apply gray frame to current frame
                        cv2.imshow('Video Part 2', grayFrame) # shows video in grascale 
                        if cv2.waitKey(1) == 27:
                            break
                    else : 
                        break
                except :
                    print("error occured")
capture.release() cv2.destroyAllWindows()