Black screen detection

hello, i’m trying to develop a script that annotates the black screen in video and i used the windowing method to combine frames and make it more accurate but lately i’ve been struggling to understand how it works exactly i couldn’t find a direct results