There even is a project that uses machine learning to detect sponsor segments. https://github.com/xenova/sponsorblock-ml
3 points
MythTV has a broadcast television ad detection module and it works pretty damn well.
This goes into a bit of detail on itβs methods:
https://www.mythtv.org/wiki/Commercial_detection
A lot of what it does could be applied to a video stream, although adapting it to useful real-time could be tricky.