<p>I can think you should try this project, <a href="https://github.com/nielstenboom/recurring-content-detector" rel="nofollow noreferrer">https://github.com/nielstenboom/recurring-content-detector</a>. I would recommend trying the Color Histogram or Color Texture Motion algorithms. The Convoluted Neural Network one is quite compute intensive and the results haven’t been that good for me. Since your looking for such a small clip, you might need to reduce the frame skip parameter to get more accurate timings.</p>

CC BY-SA 4.0
2020-12-19T18:41:40.470Z
Exactly what I am looking for, but not setup to do any Python development.  Thank you!  I will take a stab at making a wrapper
Josh Stodola
CC BY-SA 4.0
2020-12-20T19:43:26.673Z
I believe you can run it as a docker container, if you don’t want to setup a full python environment with all dependencies.
Peter Grundström
CC BY-SA 4.0
2020-12-12T17:30:11.217Z
2020-12-12T17:30:11.217Z
Peter Grundström
<p>Perhaps you can export both videos (long and short) to frames and then use duplicate image finder software to identify the matching frames?<br />
I don't have concrete suggestions, but overall the process would be:</p>
<ol>
<li>Export the short video to frames to one folder, the filename of every frame should be the timecode of that frame for easy identification and sorting. <a href="https://stackoverflow.com/a/50100263/1256347">This answer on StackOverflow</a> explains partially how to do this with <code>ffmpeg</code>.</li>
<li>Export the long video to frames in a similar way</li>
<li>Get a duplicate image finder, a web search will turn up many. Ensure that the software uses the content to identify duplicates, not the metadata. <a href="https://photo.stackexchange.com/q/14094/9161">This Photo.SE question</a> has some suggestions.</li>
<li>Take the first frame of the short video and set it as your reference image in your duplicate finder and run the software in the folder that contains the frames from your long video.</li>
<li>If all goes well the software will return a set of frames that visually match the reference frame. From the filename of those matches you can identify the timecode.</li>
</ol>

CC BY-SA 4.0
2020-11-11T17:09:37.533Z
Thank you for the reply, I am looking for something much more efficient.  I was thinking some way to hash a sequence of frames and scan for it with a filter.  The video equivalent of the classic Shazam app, if you will.  I know it will be an intensive operation, but I can not consider exporting every frame.
Josh Stodola
CC BY-SA 4.0
2020-11-11T17:43:47.887Z
I would also prefer a shazam like app, but I was not able to find one. Hopefully someone else can suggest it. But exporting every frame maybe sounds a more labour intensive than it is: ffmpeg can do this fairly quickly, you just need some spare harddisk space ([relevant question on SO](https://stackoverflow.com/q/10957412/1256347)). Perhaps you can indicate in your question why exporting every frame is not an option? Is there some diskspace requirement?
Saaru Lindestøkke
CC BY-SA 4.0
2020-11-11T14:30:35.317Z
2020-11-11T17:48:07.193Z
2020-11-11T17:48:07.193Z
Saaru Lindestøkke
<p>I have a five second clip that is stripped from a much longer video.  I need to identify exactly where in the longer video this clip begins/ends.  There could be multiple occurrences of the clip, I would like to identify them all, not just the first one.  How would I go about doing this?</p>
<p>I have used the <a href="https://ffmpeg.org/ffmpeg-filters.html#mpdecimate" rel="nofollow noreferrer">mpdecimate</a> filter in ffmpeg to identify repeated frames before, but I can't quite think of anything to use for this specific task of searching for a video within a video.</p>

<ffmpeg>
Search two hour video for a specific five second clip
Josh Stodola
# Search two hour video for a specific five second clip

(Asked by: username_0 on 2020-11-10)

I have a five second clip that is stripped from a much longer video. I need to identify exactly where in the longer video this clip begins/ends. There could be multiple occurrences of the clip, I would like to identify them all, not just the first one. How would I go about doing this?

I have used the [mpdecimate](https://ffmpeg.org/ffmpeg-filters.html#mpdecimate) filter in ffmpeg to identify repeated frames before, but I can't quite think of anything to use for this specific task of searching for a video within a video.

**Tags:** ffmpeg


---

## 2 answers

### Answer by username_1 on 2020-12-12. Score: 2

I can think you should try this project, <https://github.com/nielstenboom/recurring-content-detector>. I would recommend trying the Color Histogram or Color Texture Motion algorithms. The Convoluted Neural Network one is quite compute intensive and the results haven’t been that good for me. Since your looking for such a small clip, you might need to reduce the frame skip parameter to get more accurate timings.

> **Comments:**
> **username_0**: Exactly what I am looking for, but not setup to do any Python development.  Thank you!  I will take a stab at making a wrapper  
> **username_1**: I believe you can run it as a docker container, if you don’t want to setup a full python environment with all dependencies.  

---

### Answer by username_2 on 2020-11-11. Score: 0

Perhaps you can export both videos (long and short) to frames and then use duplicate image finder software to identify the matching frames?  
I don't have concrete suggestions, but overall the process would be:

1. Export the short video to frames to one folder, the filename of every frame should be the timecode of that frame for easy identification and sorting. [This answer on StackOverflow](https://stackoverflow.com/a/50100263/1256347) explains partially how to do this with `ffmpeg`.
2. Export the long video to frames in a similar way
3. Get a duplicate image finder, a web search will turn up many. Ensure that the software uses the content to identify duplicates, not the metadata. [This Photo.SE question](https://photo.stackexchange.com/q/14094/9161) has some suggestions.
4. Take the first frame of the short video and set it as your reference image in your duplicate finder and run the software in the folder that contains the frames from your long video.
5. If all goes well the software will return a set of frames that visually match the reference frame. From the filename of those matches you can identify the timecode.

> **Comments:**
> **username_0**: Thank you for the reply, I am looking for something much more efficient.  I was thinking some way to hash a sequence of frames and scan for it with a filter.  The video equivalent of the classic Shazam app, if you will.  I know it will be an intensive operation, but I can not consider exporting every frame.  
> **username_2**: I would also prefer a shazam like app, but I was not able to find one. Hopefully someone else can suggest it. But exporting every frame maybe sounds a more labour intensive than it is: ffmpeg can do this fairly quickly, you just need some spare harddisk space ([relevant question on SO](https://stackoverflow.com/q/10957412/1256347)). Perhaps you can indicate in your question why exporting every frame is not an option? Is there some diskspace requirement?  

---

