scc
scc

Reputation: 10716

Detect frames that have a given image/logo with FFmpeg

I'm trying to split a video by detecting the presence of a marker (an image) in the frames. I've gone over the documentation and I see removelogo but not detectlogo.

Does anyone know how this could be achieved? I know what the logo is and the region it will be on.

I'm thinking I can extract all frames to png's and then analyse them one by one (or n by n) but it might be a lengthy process...

Any pointers?

Upvotes: 2

Views: 3537

Answers (3)

Adrian Harle
Adrian Harle

Reputation: 1

I have successfully detect logo using a rpi and coral ai accelerator in conjunction with ffmeg to to extract the jpegs. Crop the image to just the logo then apply to your trained model. Even then you will need to sample a minute or so of video to determine the actual logos identity.

Upvotes: 0

d33pika
d33pika

Reputation: 2017

You can write a detect-logo module, Decode the video(YUV 420P FORMAT), feed the raw frame to this module, Do a SAD(Sum of Absolute Difference) on the region where you expect a logo,if SAD is negligible its a match, record the frame number. You can split the videos at these frames. SAD is done only on Y(luma) frames. To save processing you can scale the video to a lower resolution before decoding it.

Upvotes: 2

user149341
user149341

Reputation:

ffmpeg doesn't have any such ability natively. The delogo filter simply works by taking a rectangular region in its parameters and interpolating that region based on its surroundings. It doesn't care what the region contained previously; it'll fill in the region regardless of what it previously contained.

If you need to detect the presence of a logo, that's a totally different task. You'll need to create it yourself; if you're serious about this, I'd recommend that you start familiarizing yourself with the ffmpeg filter API and get ready to get your hands dirty. If the logo has a distinctive color, that might be a good way to detect it.

Since what you're after is probably going to just be outputting information on which frames contain (or don't contain) the logo, one filter to look at as a model will be the blackframe filter (which searches for all-black frames).

Upvotes: 3

Related Questions