Hello!
You can try Xeoma software. It has a “Motion detection module”, which allows to record only when motion is triggered. It allows you to set motion detection in the given area, motion cessation, penetration into the forbidden zone, detect staying in the zone. The scale of sensitivity level lets you know what speed and rate of motion is needed to make your system react. Moreover, this functionality is absolutely free!