4

everyone!

I process video from IP cameras and have wrote a motion detection algorithm based on decompressed video analysis. But i really something more fast. I've found several papers about compressed domain analysis but have failed to find any implementations. Can anyone recommend me some code?

found materials:
http://www.ist-live.org/intranet/school-of-informatics-university-of-bradford001-7/41410206.pdf/view
http://doc.rero.ch/lm.php?url=1000,43,4,20061128120121-NA/Bracamonte_Javier_-_A_Low_Complexity_Change_Detection_Algorithm_20061128.pdf

paft
  • 121
  • 2
  • 8
  • 1
    Are you trying to detect motion in video streams or in JPEG frames? It's not that difficult to detect motion in a compressed video stream's P and B frames since the only thing which gets compressed is the frame to frame changes. A series of JPEG images is a different story since each frame is completely intra-compressed. Working with the frequency domain of JPEG images would be challenging, but I suppose you could check the sum of absolute differences inter-frame for each MCU. The sums and positions of the changes would alert you to motion. – BitBank Apr 11 '12 at 21:39
  • Yes, I detect motion in video streams from ip-cameras. Video stream can be one of three popular types: MJPEG (JPEG image series, but as I know it's still possible to detect changes between them without full recompression), MPEG4 and H.264. It would be good to start from any of the given stream types. – paft Apr 18 '12 at 05:59
  • Related: https://dsp.stackexchange.com/questions/32276/how-to-detect-and-capture-scene-change-in-a-recorded-video – Vadzim Jun 14 '18 at 20:52

2 Answers2

3

I had to detect motion in H.264-video, and for me the frame size was a really good indicator.

I used ffprobe (from the ffmpeg project) to export frame sizes like this:

./ffprobe -show_frames -pretty video.mp4 | grep 'size' | grep -o '[0-9]*' > sizes.txt

In my case no movement meant larger I-frames (for me, every 30th frame was an I-frame) and smaller sizes for some of the frames in between.

I'm new to video encoding so I guess these things might be very dependent on encoding and type of video signal, but it's worth a look since it's very fast to try out. Export framesizes and have a look in e.g. Matlab.


Edit: In the end I re-encoded the video so that every second frame was an I-frame, as this gave better time resolution. One idea I did not test was to reverse the video and do the same thing, this should give more accurate estimations of when the motion started/ended, akin to removing the phase delay by forward-backward filtering.

Erik
  • 2,500
  • 2
  • 13
  • 26
0

https://github.com/Breakthrough/DVR-Scan

DVR-Scan is a cross-platform command-line (CLI) application that automatically detects motion events in video files (e.g. security camera footage). In addition to locating both the time and duration of each motion event, DVR-Scan will save the footage of each motion event to a new, separate video clip. Not only is DVR-Scan free and open-source software (FOSS), written in Python, and based on Numpy and OpenCV, it was built to be extendable and hackable.

I can confirm that it works perfectly with MPEG4 (H264) AVI files. Scanning speed is about 30 fps at my laptop with i5 4300U CPU for 1200x900 video.

You can check the sources for the algorithm used.

And here are some explaning tutorial links from the same author: https://github.com/Breakthrough/python-scene-detection-tutorial

See also Python scene change detection.

Vadzim
  • 24,954
  • 11
  • 143
  • 151