python - Create a video of layered videos -
i'm python , opencv beginner! create video made of 3 others videos. each video moving car on black background
i created video empty moment:
video_summary=cv2.videowriter(video_output_path ,fourcc,video_fps ,(480,270), true)
now, add videos called 0, 2 , 4 "video_a_ajouter" in video_summary.
video_a_ajouter=[0,2,4] video_working=[]
so, did this:
for in video_a_ajouter: video_working.append(cv2.videocapture(output_directory_path+'output_tp_'+str(video_a_ajouter[0])+'.avi')) video_a_ajouter.remove(video_a_ajouter[0])
i know how put 3 videos in video_summary, considering 0 overlaps 2 , 2 overlaps 4
thank in advance !! :)
i'm not sure mean "made of 3 other videos", here 2 ideas:
1) 3 videos seen 1 after in succession:
if case, can check if current video finished. if isn't, add frame, else append frame next video:
ret1,img1=cap1.read()//read 1st video ret2,img2=cap2.read()//2nd ret3,img3=cap3.read()//3rd if(cap1.isopened()): video_summary.write(img1) elif(cap2.isopened()): video_summary.write(img2) elif(cap3.isopened()): video_summary.write(img3)
2) need overlay 3 videos 1 on another:
in case, should addweighted function