1

I want to extract keyframes from a video. Now I'm using a loop that compare the samples of one frame with the samples of the preceding frame, but this method isn't very good.

Let me explain: I have a surveillance video and I have to select the frames where there is a change (a person appears, another person appears, a person goes away, etc.) Now I'm using this class to compare frames: Java Image Comparison / Motion Detection Class

Do you know other ways?

Thanks!!

Mark Design
  • 664
  • 1
  • 6
  • 24

1 Answers1

4

I'm not sure what you call a "keyframe". Your method would allow you only to find scene transitions, but that is not what is usually meant by a "keyframe" in video decoding: it's rather usually an I-frame (a frame which can be decoded on its own, without reference to other frames). (Frequently scene transitions are keyframes, but no necessarily the other way). This concept it tied to the video codec, of course, but most modern codecs (from MPEG-1) implement this concept. But notice that this is not related to the raw pictures in themselves, but with the codec.

If you want to detect these keyframes (I-frames), then you must look inside your video decoding API, to see if it allows you to get this information. It seems that xuggle provides you the IVideoPicture.getPictureType() method, but I have not used it.

leonbloy
  • 73,180
  • 20
  • 142
  • 190
  • Thanks for this explanation but I'm searching a method to find scene transitions, let me explain: I have a surveillance video and I have to select the frames where there is a change (a person appears, another person appears, a person goes away, etc.) Now I'm using this class to compare frames: http://mindmeat.blogspot.com/2008/07/java-image-comparison.html – Mark Design Jun 11 '11 at 10:25
  • Do you want to want to do it in real time or in batch mode? Why do you sat hat "this method isn't very good"? – leonbloy Jun 11 '11 at 12:59
  • I want to do it in batch mode. This method isn't very good because if my video show a running person, this method extracts every frame of the video because it find too many differences between two frames. This is the reason because I'm searching for other ways to do the keyframe extraction. – Mark Design Jun 12 '11 at 16:19
  • Ask/search for "scene transition" or "shot transition", then; not for "keyframe", as this is other concept. See eg here http://en.wikipedia.org/wiki/Shot_transition_detection – leonbloy Jun 12 '11 at 16:31
  • Simple pixel difference, with a suitable threshold and some pre-post filtering, is frequently enough. I did that once, (using avisynth http://avisynth.org/mediawiki/ScriptClip) with quite good results. – leonbloy Jun 12 '11 at 16:35