I'm trying to create an app with openframeworks, which has a live camera, and when it detects motion, it starts to record the video for 3 seconds and creates a.gif.

Does anybody know how to to this?

The part of motion detection is done with OpenCV.