Building a Live Sports Commercial Blackout Tool
I built a Windows desktop tool to make watching live sports more enjoyable: when it detects that a game has gone to a commercial break, it covers the selected display with a black overlay and mutes the target browser. When the broadcast returns, it restores the picture and audio.
What began as an ad-blocking idea turned into a systems problem. Live sports do not consistently display a simple “Ad” label, and the on-screen graphics can change during replays, camera cuts, and breaks in play. The app therefore looks for signs that the broadcast is still live instead of relying on one commercial badge.
- Windows 11 desktop application built with Python
- Screen capture and visual matching with MSS and OpenCV
- Baseball and football profiles, with automatic sport switching
- Football scoreboard OCR as an additional detection signal
- Configurable, borderless blackout overlay and browser audio control
How the detection works
In sports mode, the app captures frames from a selected monitor and checks configured regions for two visual anchors: the scoreboard and the broadcast watermark or channel bug. OpenCV compares those regions with calibrated templates. The settings file stores sport-specific templates, regions of interest, and confidence thresholds, so the detection can be tuned for the graphics and display being used.
Football broadcasts also have an OCR fallback. It looks for a game clock together with a period or down-and-distance cue. This gives the football profile a second way to recognize live play when a fixed scoreboard image is not a good match.
The application includes baseball and football profiles and can switch between them after confirming the alternate sport over multiple frames. There is also a separate badge-detection mode for on-demand content that uses an on-screen ad or commercial indicator.
Avoiding false blackouts and premature recovery
A scoreboard can disappear during a replay, and broadcast logos can remain on screen during commercials. Treating either one as a definitive answer would cause distracting flashes or restore the picture at the wrong time.
While the picture is visible, the sports detector can keep it visible when the scoreboard or broadcast bug indicates game coverage. It uses debounce and grace periods to tolerate brief changes. Once the display has blacked out, recovery is stricter: the detector requires a confirmed scoreboard match (or football OCR), rather than reopening the picture just because a familiar channel logo appears.
These rules are configurable. That made it possible to tune the trade-off between reacting quickly and avoiding false transitions, while keeping the code adaptable to different broadcast layouts.
Windows display and audio integration
Detection is only one part of the tool. When a commercial break is confirmed, a PyQt6 overlay creates a borderless, always-on-top blackout on the target display. The audio component mutes the selected browser process, such as Chrome, Brave, or Edge. When live content is confirmed again, the overlay and mute are cleared.
Monitor selection, browser executables, capture rate, templates, and detection settings are kept in configuration rather than being hard-coded into the detection logic. Calibration commands and status logs help inspect what the detector sees and diagnose missed or premature transitions.
Limitations and lessons
This is visual detection, not a universal way to identify every advertisement. Broadcast graphics vary by sport, network, and layout, and OCR or template matching can miss unfamiliar graphics or mistake similar ones for a match. The app currently includes baseball and football sports profiles; other broadcasts may need their own calibrated templates and tuning.
The project gave me practical experience connecting screen capture, image processing, OCR, Windows audio control, display configuration, and a desktop UI into one application. It also reinforced a troubleshooting habit that applies beyond this project: make system state observable, isolate the signal that caused a transition, and tune one variable at a time.
Source code
The project source and setup instructions are available on GitHub: sports-ad-blocker.
This project sits at the intersection of IT support and engineering: it has to work with real Windows processes, displays, and audio devices, while the detection logic has to stay reliable as the broadcast changes.