[gst-devel] keyframes from a video

Tim-Philipp Müller t.i.m at zen.co.uk
Mon Aug 3 13:20:31 CEST 2009


On Fri, 2009-07-24 at 11:20 +0200, kitone wrote:

Hi,

> I'm the developer of subtitleeditor[1] and i'm currently rewriting the
> gstreamer support. I need to display the position of the keyframes on
> the waveform, and for that I need to extract all keyframes from a video
> and keep this values in a array.
> 
> My current method is to play the lvideo something like this: 
> 
> 'filesrc ! decodebin ! ffmpegcolorspace ! fakesink' 
> 
> Connect the 'handoff' signal of my fakesink and check if the buffer has
> a flag GST_BUFFER_FLAG_DELTA_UNIT. If yes, add a keyframe in an array.
> 
> It work pretty well, but it's also a little slow.

There are a couple of problems with this approach:

 - if GST_BUFFER_FLAG_DELTA_UNIT is set this means that the buffer does
*not* contain a key frame

 - decodebin outputs decoded raw video frames; I don't think the
semantics of keyframe/not-keyframe are very well defined for raw video
frames. I would not rely on decoders flagging their output buffers
consistently one way or another or at all

 - you are likely to get better results if you check for keyframes on
buffers before they go into the decoder

> Is there an another way to get all keyframes from a video?

 - I guess GstIndex would theoretically be the right way to get to this
kind of information (idea is that demuxer or whatever populate the index
object with the information), but I don't think this is supported very
well, or at all, in most of our elements. Not sure what plans are here
(ie. if GstIndex support should be implemented widely, or if a new API /
mechanism should be found etc.)

 Cheers
  -Tim





More information about the gstreamer-devel mailing list