As for home surveillance, I have the following 2 setups:
Linux box with zoneminder, which offers motion detect, history, alerts via email, FTP upload, USB and network cameras. And the cameras which aren't supported, they have a FTP client with motion detection, to that linux box, and the uploaded videos from the cameras, I convert them from avi to mp4 and use rclone to copy the resulting videos on my nextcloud server, so that, I can access videos from both zoneminder and FTP on my phone, as well, having a backup elsewhere.