Detect if video file contains movement

11,952

Solution 1

You can check dvr-scan which is simple cross-platform command line tool based on OpenCV.

To just list motion events in csv format (scan only):

dvr-scan -i some_video.mp4 -so

To extract motion in single video:

dvr-scan -i some_video.mp4 -o some_video_motion_only.avi

For more examples and various other parameters see: https://dvr-scan.readthedocs.io/en/latest/guide/examples/

Solution 2

I had the same problem and wrote the solution: https://github.com/jooray/motion-detection

Should be fairly easy to use from command-line.

Solution 3

If you would like to post-process already-captured video then motion can be useful.

VLC allow you to stream or convert your media for use locally, on your private network, or on the Internet. So an already-captured video can be streamed over HTTP, RTSP, etc. and motion can handle it as a network camera.

Furthermore: How to Stream using VLC Media Player

Solution 4

If OpenCv is to advanced for you, maybe you should consider something easier which is... SimpleCV (wrapper for OpenCV) "This is computer vision made easy". There is even an example of motion detection using SimpleCV - https://github.com/sightmachine/simplecv-examples/blob/master/code/motion-detection.py Unfortunetely i can't test it(because my OpenCv version isn't compatible with SimpleCV), but generally it looks fine (and isn't complicated) - it just substract previous frame from current and calculate mean of the result. If this value is bigger than some threshold (which most likely you will have to adjust) than we can assume that there were some motion between those 2 frames. Note that setting threshold to 0 is really a bad idea, because always there is some difference between 2 consecuitve frames (changes of lighting, noises, etc).

Share:
11,952
Joel L
Author by

Joel L

I make useful web things

Updated on August 19, 2022

Comments

  • Joel L
    Joel L over 1 year

    I have a bunch of video clips from a webcam (duration is 5, 10, 60 seconds), and I'm looking for a way to detect "does this video clip have movement", to decide whether the file should be saved or discarded in a future processing phase.

    I've looked into motion and OpenCV, but motion seems to only want to work on the raw video stream, and OpenCV seems to be way too advanced for my use.

    My ideal solution would be a linux command-line tool that I can feed video files into, and get a simple "does/doesn't contain movement" answer back, so I can discard the irrelevant files. False positives (in a reasonable quantity) are perfectly acceptable for my use.

    Does such a tool exist? Or any simple examples of doing this with other tools?