At first I tried all kinds of methods to turn it on only when there was something interesting to avoid drowning in terabytes of data, detecting things like: cars, people, animals. I tried classical image processing methods, and tools like Motion, then tried similar image compression algs to find significant macroblocks; then I tried all types of methods in OpenCV; next came several neural nets with off-the-shelf YOLO/SSD object detection (using Google TFUs, Nvidia Jetsons), I even tried retraining the networks with my own tiny dataset.
In the end, everything sucked with too many false positives blowing up my cloud alert SMS traffic to myself. So now I just record 6 cameras nonstop to files. I don't get the benefit alerts, but nothing much happens, and if it does, I have history recorded.
It was a fun project, I tried all kinds of codecs, cameras, languages, frameworks, hardware, etc. I even started out trying to do custom battery-powered wireless device using a raw Chinese MIPI CCDs and building my own WiFI station. I spent over 3 years on it, just to end up with your basic CCTV box. But it was fun!