How to check if videos overlap
<p>I am new to video analysis and python and is working on a project on video composition. I have three videos that overlap.
for example below are the start and end time of the videos</p>

<pre><code>       video1     video2     video3
start  19-13-30   19-13-25   19-13-45
end    19-13-55   19-13-35   19-13-59
</code></pre>

<p>In the above scenario video1 &amp; video2 overlap for 5 sec(19-13-30 to 19-13-35) and video1 and video3 overlap for 10 sec(19-13-45 to 19-13-55).</p>

<p>So,is there a way to identify the overlaps in the videos given the timestamps and returning the timestamps for which they overlap or by just analyzing the video</p>

<p>Suppose you have a list of starttime and endtime of the videos [[video1_starttime,video1_endtime],[video2_starttime,video2_endtime],[video3_starttime,video3_endtime]], you can first sort the list based on startimes and then iterate over it to check if it is overlapping.</p>

<p>You can use the below code to check for it:</p>

<pre><code>overlapping = [ [x,y] for x in intervals for y in intervals if x is not y and x[1]&gt;y[0] and x[0]&lt;y[0] ]
for x in overlapping:
    print '{0} overlaps with {1}'.format(x[0],x[1])
</code></pre>

<p>where intervals is the list of <code>[starttime,endtime]</code></p>

<p>To compare the timestamps, convert them to datetime objects using:</p>

<pre><code>from datetime import datetime
dateTimeObject = datetime.strptime(timestampString)
</code></pre>

python timestamp video-processing