Hello I have multiple videos which overlap at some time and want to stitch these videos to get a single video stream.
for example below are three videos where video 1 and video 2 overlap at some time
Now I wanted the final o/p to be
Where initially video 1 frames are read and written to the video writer object until there is an overlap. Once there is an overlap the view switches from video 1 or video 2 based on some decisions(which is not my question). Once the overlap ends the frames from video 2 are read and written as the video 1 frames are completed. And finally when they are no frames left from video 2, frames from video 3 are read and written.
My question is how to read and write the overlapped videos as i wanted to have the frames from video or video 2 for the overlapped period. The problem I am facing is how to identify the overlap while reading and writing the frames without checking the video content.
I am finding the overlapped time by analyzing the time stamps and also getting the video indices for which there is an overlap. So, how can I use this information to read and write frames for overlapped videos. Below is the on how I am getting the information which will be used for writing
def dict_cam(key,values):
return {key[i]:values[i] for i in range (len(key))}
users=dict_cam(indices,intervals) # Creates dictionary with videos indices as keys(indices) with their start and end time as their values(intervals).
overlapping = [ [i,j,x,y] for i,x in users.iteritems() for j,y in users.iteritems() if x is not y and x[1]>y[0] and x[0]<y[0] ] # For identifying overlapping.
for x in overlapping
camera=[x[0]]
camera.append(x[1])
begin=x[2][0]
end=x[2][1]
begg=x[3][0]
ens=x[3][1]
if begin < begg and begg<end:
overlap.append(begg)
if ens < end:
overend.append(ens)
else:
overend.append(end)
over_rang=overlap + overend
Where, camera is a list of video indices where there is an overlap, and over_rang is a list which contains the duration of the overlap.
Before starting video writing I am sorting all the video indices with their start time.
I do not want to analyze the video content rather use the information about the overlapped time and the indices where there is a overlap.