I have video files recorded by a surveillance camera. Every file is 24 hours long.

While I use Linux' motion to do motion detection in real time directly from the camera, I also would like to check for motion from the previously recorded videos.

I searched for both Linux and Windows applications to do that, but my search was inconclusive. I found:

  • Suggestions to use motion and stream video content to it through /dev/video0. Those suggestions seemed way too technically complex for me.

  • Instructions to use VLC to detect motion. However, VLC will only play a video and highlight the motion, and I can hardly imagine myself watching a 24-hours video in a hope that VLC will suddenly highlight a change that I would see anyway.


What could I use, in Linux or Windows, to extract from a video file the frames which correspond to motion, while ignoring everything else?

In other words, taking as input a 24 hours long video where nothing happens except the 10 seconds moment where someone opens the door and gets in, how do I get as output the corresponding 10 seconds video (or a bunch of JPEG images corresponding to this time lapse)?

1 Answer 1


There is a quite simple to follow set of instructions of how to do what you are asking using OpenCV and python, (actually targeted on Live Detection but you can use any video source), available at PyImageSearch in two blog posts: motion detection and home surveillance.

The blog posts show how to use OpenCV to use a video source such as a Raspberry Pi camera, but a file will do, perform motion detection, generate a set of stills for the period that motion was detected, with date/time stamps, and upload them to Dropbox but of course they can just be saved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.