Merging two videos while skipping common parts

1

A customer has a collection of tutorial videos, all of which have the following structure:

  1. preview (or recap)
  2. intro (always identical)
  3. repeated part from previous video (optional)
  4. new content
  5. outro

I am tasked with merging those videos by creating one video for about every 10 videos containing only ONE intro, one OUTRO and the content from all 10 videos.

The problem is variable repeated parts from the preceding video that I don't want to duplicate. My first idea was to extract all frames (or only keyframes) with ffmpeg and mux them with framemd5. Then compare the resulting stream of md5 to decide where repeated content stops.

This approach seems a bit too unforgiving as I can not assume that the same frame gets encoded perfectly identical in both videos. The next idea is to generate a histogram for every frame and then match the function of the histogram between the videos with some measure of tolerance (5%?).

Another Idea was to use OpenCV and execute matchTemplate to find similar pictures, but this would need to run on every frame and i think that it would run into performance problems really fast.

Are there any tried and true solutions for this problem? Or maybe experimental solutions? Can I generate a framehistogram with ffmpeg in the same same way that framemd5 works?

Any idea what technique Youtube uses to match copyrighted content in uploaded videos?

Igor Skoric

Posted 2017-01-19T12:08:35.070

Reputation: 111

How long is the 'new content' in a video and what's the duration (range) of repeated part? Is there any distinct audio/video part at start of new content, like a title screen or lower third? – Gyan – 2017-01-19T17:11:22.240

New content is about 15 minutes. The repeated part is about 45 seconds. There is unfortunately no distinct part immediately before new content. Thank you for your consideration. – Igor Skoric – 2017-01-19T21:07:33.817

What's the transition between repeated content and new? Crossfade? – Gyan – 2017-01-20T05:29:35.177

No, the crossfade is in between intro and repeated content if there is repeated content (optional). – Igor Skoric – 2017-01-22T05:23:24.060

No answers