Ideally you would want to analyze a live video buffer without actually saving it on the fly, and perhaps apply some sort of levels filter to better detect on-off events.