How to detect Video Input Static with OpenCV

Do you have an idea how can I detect all different static in a real time video input using OpenCV?
My goal is to detect static in the video input stream and cut the recording, as it is unsignificant footage. Is there a simple way for detecting static using OpenCV? Thanks for your support!

crosspost:

(copied from the other site for posterity)

That’s high-frequency noise. You’ll want a filter that is sensitive to it.

The difference between local maximum and local minimum reacts well:

n = 3 # adjust that down for finer discrimination
localmax = cv.dilate(pic, None, iterations=n)
localmin = cv.erode(pic, None, iterations=n)

localmax, pic, localmin for your first picture:

Difference, for each of your pictures:

diff = cv.subtract(localmax, localmin)

You see, the first one reacts overwhelmingly. The second one also reacts, across most of the image, but less strongly.

Now you can calculate a histogram over these differences, as well as a cumulative distribution:

hist, bins = np.histogram(diff.flatten(), 256, [0, 256])
cdf = hist[::-1].cumsum()[::-1]

plt.xlim([256, 0])
cdf_normalized = cdf * hist.max() / cdf.max()
plt.plot(cdf_normalized, color='r')
plt.hist(diff.flatten(), 256, [0, 256], color='b')
plt.show()

You see, if you set some threshold on the differences, you can tell how much of the picture is (at least) that noisy. In the first picture, even a high threshold still captures most of the area. It’s clearly noisy. In the second picture, only a small part of it is very noisy (higher threshold), but most of it is at least a little noisy (lower threshold).

You decide where you want your difference threshold and how much of the picture is allowed to be above the threshold.

This method will also react to edges and other “content” in the image. That is unavoidable.

One could come up with an alternate approach that’s more solidly based in statistics, but might require your video to not be upscaled from the original analog/digital conversion. The second picture’s noise shows that the picture comes from an analog signal that has some lower-frequency noise in it. As such, pixels in the same row correlate (left/right neighbor), while pixels across rows (neighbors to the top and bottom) hardly correlate at all.