How to detect commercials in recorded TV stream?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to detect commercials in recorded TV stream?

Bo Berglund
I am using ffmpeg in scripts to download from a live stream TV channel nightly
so I can view the shows in the morning.

To remove the commercials I have written a video editing program with which I
can scan through a video and put markers for sections to keep, then finally use
these markers to have ffmpeg extract the "good" sections into a final
commercial-free video to watch.

But even though I have speed buttons to jump around in the video while finding
the start and end positions of the commercials it gets tedious to do manually...

So I wonder if there is any function in ffmpeg I can use to extract scene change
points which I can then use when setting the cut points?

I figure if I have a list of suggested points I could load that into my program
and quickly verify if they are OK or not by jumping among them.

But the big question is really how to make ffmpeg find the change points?


--
Bo Berglund
Developer in Sweden

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to detect commercials in recorded TV stream?

Peter White
On Sat, Mar 27, 2021 at 08:15:23AM +0100, Bo Berglund wrote:

> I am using ffmpeg in scripts to download from a live stream TV channel nightly
> so I can view the shows in the morning.
>
> To remove the commercials I have written a video editing program with which I
> can scan through a video and put markers for sections to keep, then finally use
> these markers to have ffmpeg extract the "good" sections into a final
> commercial-free video to watch.
>
> But even though I have speed buttons to jump around in the video while finding
> the start and end positions of the commercials it gets tedious to do manually...
>
> So I wonder if there is any function in ffmpeg I can use to extract scene change
> points which I can then use when setting the cut points?

One thing that springs to mind is skipping non-key frames. Since modern
codecs put keyframes where they detect a scene change, the odds are good
that there will be a keyframe at the start and end of commercials. Of
course there will be a lot more keyframes for the normal scene changes
in the content you do want, but skipping through those should be quicker
than skipping by a fixed amount of time.

I also seem to remember that there are some filters that can detect the
start of commercials, by leveraging the logo of the station which
usually is not shown during those breaks. But I have no idea if such
filters exist for ffmpeg.


Cheers,
Peter
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to detect commercials in recorded TV stream?

Rob Hallam-2
On Sat, 27 Mar 2021 at 11:39, Peter White <[hidden email]> wrote:
>
> On Sat, Mar 27, 2021 at 08:15:23AM +0100, Bo Berglund wrote:
> > I am using ffmpeg in scripts to download from a live stream TV channel nightly
> > so I can view the shows in the morning.
>
> I also seem to remember that there are some filters that can detect the
> start of commercials, by leveraging the logo of the station which
> usually is not shown during those breaks. But I have no idea if such
> filters exist for ffmpeg.

Another observation which used to hold true- commercials used to be louder
on average than the main programme, at least in the anglosphere. Perhaps the
list of keyframe candidates to skip between could be narrowed down based on
audio, or a sudden change in audio level.

If you know the rough time interval on which commercials occur, eg
around 15 / 20
minutes, that could also filter out keyframe candidates.

However, as Peter says, it would be worth tracking down other projects that
do advert break detection before coming up with your own heuristics as the
work may already have been done for you!

Cheers,
Rob
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to detect commercials in recorded TV stream?

FFmpeg-users mailing list
Rob Hallam <[hidden email]> writes:

> On Sat, 27 Mar 2021 at 11:39, Peter White <[hidden email]> wrote:
>>
>> On Sat, Mar 27, 2021 at 08:15:23AM +0100, Bo Berglund wrote:
>> > I am using ffmpeg in scripts to download from a live stream TV channel nightly
>> > so I can view the shows in the morning.
>>
>> I also seem to remember that there are some filters that can detect the
>> start of commercials, by leveraging the logo of the station which
>> usually is not shown during those breaks. But I have no idea if such
>> filters exist for ffmpeg.
>
> Another observation which used to hold true- commercials used to be louder
> on average than the main programme, at least in the anglosphere. Perhaps the
> list of keyframe candidates to skip between could be narrowed down based on
> audio, or a sudden change in audio level.
>
> If you know the rough time interval on which commercials occur, eg
> around 15 / 20
> minutes, that could also filter out keyframe candidates.
>
> However, as Peter says, it would be worth tracking down other projects that
> do advert break detection before coming up with your own heuristics as the
> work may already have been done for you!

Mythtv has decent commercial detection. I am pretty sure that you can
even set it up to record those streamed videos, and then run commercial
detection immediately afterward. The frontend has a built-in editor that
lets you review and revise the cut points. There are loads of scripts
out there that use ffmpeg to then remove the cuts.

Having said that, ffmpeg has the blackdetect, blackframe and
silencedetect filters, which may serve your narrowly-stated purpose. In
the US, they likely won't, but elsewhere they may work better.

Leo
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".