Creating an Ad Blocker for Cracked NBA Streams
Uploaded on February 3, 2026
I love the NBA and I hate ads. Ads work on everybody, and being aware of certain products and services lead you to spend money on these products and services. I want to watch the NBA but I don't want to listen to any ads. I also do most of my sports consumption while I'm doing something else like drawing or coding. I want to be able to listen to what's going on while doing something else, and I don't want to listen to the ads. When ads come on I'll get pissed because ads are annoying and I don't want to buy their crap (and half of the time the ads are for a Chevy dealership in a city that I don't live in). So I mute the stream. The problem is that then I forget to unmute the stream, and I miss a huge chunk of the game. So I decided that I would write a program to automatically mute ads and then unmute when the game comes back on.
I started thinking about solutions, at first I looked for datasets on HuggingFace for advertisements, then I tried to see if I could do speech to text and detect text based on certain words, but this solution was really finnicky. Finally I realized that it's immediately obvious to tell by listening to the audio if you're listening to NBA audio or ad audio. I thought about it in terms of soundwaves – I felt like I could probably look at an image of a waveform of audio of an ad and one of an NBA game and reasonably well determine if it's an ad or audio.
I started looking into this more, and I realized a more detailed, higher accuracy version of this is to use Spectrograms.
So, I decided what I would do is train a CNN to learn what an NBA game sounded like, and what an ad sounded like (since I couldn't find any good datasets), and then write a Python script to determine whether an audio stream was an NBA game or an advertisement. If it's an advertisement, I would mute the audio, and if it was a game I would unmute the audio.
Questions
Immediately, the question I had was: "If I'm muting the audio, how will I know when to unmute? There's no audio." Maybe the answer is obvious, but essentially I would download (not create – that's overkill) some sort of "mixer" software that runs "in between" my Python script and the system audio. So:
I run the stream in the browser -> the mixer collects the audio data -> the script decides if its a game or an ad -> I mute/unmute system sound.
Something else a friend asked when I told him about this idea: why not do this the way AdBlock does it? That is: if you're receiving ads, you can probably see who is sending you the packets and try to determine if it's being served from some sort of "ad" server. The problem is that I watch all my sports on back-channel sports streaming sites. So everything comes through in one stream. Also – doing it this way is good because it's platform agnostic. You could be watching NBA highlights on YouTube, you could be watching League Pass, or you could be watching it on an illegal stream, and no matter what you won't hear the ad. There's also possibility for this to work on any ad, although I question the efficacy of this.
How Would I Build it?
So now that I knew what I was building, how was I going to build it? I had mentioned I couldn't find any good data sets of ad detection, so I just decided to build my own. I watched a couple nights of NBA and classify all the audio that I received from the stream by myself. I wrote a Python script that uses sounddevice to pipe my internal audio into a buffer. When I start the script, I have the script ask me to classify the audio – Ad [a], Game [g], or Unknown [u]. Whatever is currently playing I set it to, and then I let the script go to work. Every two seconds it takes the last 2 seconds of audio, save it as a .wav and then write it to ./labeled_audio/ad | game (based on what I currently have the script set to. So let's say when I start the script I'm in the middle of the game. I start the script, press g, and let it go for a while. It'll write maybe 15 minutes of audio to the game directory, and then an ad comes on. As soon as the ad comes on I hit a in the terminal, and then it starts writing the ad audio data to the ad directory.
I did this manually for one evening, and then had a couple hours of game data and close to an hour of ad data. I assumed that an hour of each audio "type" and the fact that I thought spectrograms of the two audio types would be different enough that a CNN would do a good job of being able to differentiate between the two.
With this training data, I would then teach a CNN to predict whether an audio snippet is an ad or a game. Then I write a script that pipes my internal stream into this CNN to detect whether or not it's an ad. If it is an ad, mute the system audio. If it's not an ad, I play the audio.
Building the CNN
For each file in the training data, the script loads the audio, converts the audio to a PyTorch stensor. resamples the audio to 16khz, makes sure the length of the audio is 2s, and then converts the waveform to mel-spectrogram. It normalizes the spectrogram, and randomly applies frequency masking and Gaussian noise to each file.
Then we load these spectrograms into a 2d CNN where we treat each spectrogram as an image. We use feature extraction with three convolutional blocks. Each block uses Conv2d, BatchNorm, ReLU and MaxPool2d(2×2). The pooling reduces the frequency and spatial resolution over the network.
In the training loop I get all of the wav files and use an 80% of the files to train the model and 20% to validate the model. Then I do a forward pass to output logits. The loss is computed and then backpropagated to update the weights of the model.
After each epoch, the model is evaluated to compute the average loss and generate predictions used to produce a confusion matrix. If the validation accuracy improves, the model checkpoint is saved.
Now we have a .pt model with all the learned weights!
Using the model
Now that I have the model, I created a script that listens to the current system audio and compares the last 2 seconds to the model to determine whether or not the audio sounds like an ad or a game. If the ad logit is > 0.5, then we mute the system audio. Else, we set the system audio to whatever it was before the last time we muted!
This is a link to a Github repo containing the classification + training + muting scripts, including the .pt file. Feel free to play around with it or download the .pt file for your own personal use.
How This Could Be Used
If you own an NBA stream, you could use this stream on your own input and if the ad threshold is hit, then you could change the AV input to be something else ie.
