Search mpeg / avi frames in linux I might have an unusual problem for this site; among other duties, I manage the wireless network for a large corporate campus.  As part of an upgrade to our wireless access-points, I used a metal bracket to mount an AP on a rail about 10 feet off the ground.  When it was mounted, the bottom part of the access-point was parallel with the floor.

A week later, our cabling technicians noticed that someone had bent the AP about 70 degrees upward; given the strength of the bracket, it took a lot of force to do this.  We have a security camera about 90 feet away from this AP, but the relevant area I care about is about 3% of the camera's image area.

Due to the fuzziness and small area in the video, our security team said it would take about 30 man-hours to search the video (one person watching it for 3.5 days... given restrictions in playback, they can't zoom in during fast forward); as such, they weren't interested in going farther.

QUESTION:

It seems like there might be some way to build a list of candidate time slots in the video, where this 3% area drastically changed from normal for a given time-frame... let's say at least 20-seconds.

TBH, the bracket is only $30; however, since our old-crusty security guy swore it couldn't be automated, I took it as a point of curiosity to see whether that's true.  Obviously there are commercial solutions... I'm looking for "free" in linux.

The file would be about 6GB.  Is there a linux CLI solution to this problem?  I just need to reduce the times we look at to something manageable.  Even if I had to use a python image analytics library like OpenCV-python, that's a possibility but I'm hoping to (ab)use something like ffmpeg for this purpose.  If there isn't such a tool, which Open-CV function would be best for this job?
FFMPEG doesn't really have the tools to do motion detection out of the box. You can certainly do the cropping using the crop filter: -vf crop=w:h:x:y where w:h is the size of your cropped area and x:y its coordinates in the original image. So your ffmpeg script might look like:

ffmpeg -i input.avi -c:v libx264 -crf 20 -vf crop=123:45:67:89 output.mp4


Then you could find a frame of the output that contains no movement, export it to a still image, invert it and add it back to the video using overlay so that only parts of frames that are different would show up. Then use the blackdetect filter to find frames that are black. Then you could use some shell-fu to delete those parts of the video and finally concatenate the remainder into one clip. Whew.

…or you could use openCV. Here's a ready-rolled script that does motion detection: https://github.com/RobinDavid/Motion-detection-OpenCV