Simple TV ad blocker that switches OBS scenes based on logo detection in the top‑right corner. Uses NDI for video input and OpenCV template matching to detect when the channel logo is visible (program) vs faded/absent (ad break).
- Python 3.8+
- OBS Studio
- OBS WebSocket (v4) enabled
- obs-ndi plugin + NDI runtime
Install Python deps:
pip install -r requirements.txt
- Create two scenes:
tv
: main programadbreak
: what to show during ads (e.g., a calm video)
- Add the NDI source/filter to the
tv
scene. - Enable OBS WebSocket on port 4444 with a password.
Edit config.ini
:
[websocket]
host = localhost
port = 4444
password = secret
[opencv]
logo_path = logo.png
threshold = 0.5
interval_seconds = 1.0
roi_width_ratio = 0.25
roi_height_ratio = 0.25
[obs]
tv_scene = tv
ad_scene = adbreak
threshold
: higher means stricter logo match.interval_seconds
: how often to sample frames.roi_*_ratio
: size of top‑right region of interest.
Replace logo.png
with the channel logo (cropped and clear works best).
python main.py --config config.ini --log-level INFO
- The script reads the NDI top‑right ROI to speed up matching.
- Scenes are switched via OBS WebSocket
SetCurrentScene
. - Stop with Ctrl+C.
Leave a Reply