[FFmpeg-user] How to use ffmpeg to detect commercials

Bo Berglund bo.berglund at gmail.com
Thu Sep 30 20:41:34 EEST 2021


On Thu, 30 Sep 2021 15:45:44 +0200, "Venkateswaran.S"
<venketeswaran2015 at gmail.com> wrote:

>> I thinks it's not possible with ffmpeg command line tool. There is a
>> *delogo* filter which removes the logo from the clip but doesn't tell you
>> the timings where this logo appears.
>
>You can easily detect the logo in image using opencv lib
>> <https://ai-facets.org/robust-logo-detection-with-opencv/> . So if you
>> can understand some C or C++, you can use ffmpeg c API to get sequence of
>> avframes from your clip and feed it to opencv as an image to detect the
>> logo. You can also get the timings of that frame from ffmpeg.

This seems to be a way to detect a logo *anywhere* in an *image* even though it
is distorted and rotated.

But this is not my use case:
1) I am not dealing with an image as source, it is an mp4 video
2) I know the rect where the logo is located if it is on screen
3) I know the logo appearance, but its parts might change color from time to
time.

I want to tell ffmpeg to look at a specific rect (rather small) on screen
expressed as coordinates in percentage of w and h.

I just measured the area (w,h coordinates):
It is located at (79%,84%) and the size is (16,4%, 11,9%)

So ffmpeg/ffprobe should output a timestamp when the rect contains the logo and
when it disappears again. Those two timestamps define the time the logo is on
screen.

Can it be done?


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list