Camera.record without fixed duration

Currently, it looks like camera.record must be called with a fixed duration. I’d like to instead start recording when some sort of condition is present, and then stop recording when that condition goes away. For example, I’d like to start recording when a motion detector indicates motion is present, and then stop when motion is no longer present.