I actually just set something like this up using sentryshot and a random IP camera my dad had laying around. The docs are kinda sparse but it was simple enough to get the camera set up. It supports motion and object detection in software and I think you can set it to just record on one of those events but I haven't messed with that at all.
Edit: for remote access I'd recommend either wireguard or tailscale. I use plain wireguard without having a static IP and haven't had it break yet but your mileage may vary.
Rousing its machine spirit