[gst-devel] automagically skip parts of a stream

René Stadler mail at renestadler.de
Tue Feb 13 01:24:08 CET 2007


Am Montag, den 12.02.2007, 20:54 +0100 schrieb Rainer Clasen:
> Hello,
> 
> so far I was quite lucky using gstreamer just from the provided
> docs and googling around, but now I'm having no luck.
> 
> I'm currently searching a way to skip parts of a Media stream - or to be
> more precise, I just want to pick a bit out of the stream. The start/end
> of the part to be picked will be stored in a database. My current Idea is
> to store these positions as Nanosecond offset. 
> 
> So what's the Right(tm) way to do this?

Just seek using the correct flags (see below).
 
> Making my application seek is likely a bit kludgy - especially as this is
> not expected to happen instantious. 

If you issue a flushing seek, it happens instantaneously in the sense
that anything else that was queued before gets flushed out.  This means
that the next data to be rendered is actually the part you selected with
the seek.

> Do I have to write my own plugin for this (I guess I can take a look at
> cutter for some inspirations)? 

cutter is an audio analyzer that detects silence, I can't see how this
would help here.  You might want to have a closer look at the
documentation about seeking and segments instead:

http://webcvs.freedesktop.org/gstreamer/gstreamer/docs/design/part-seeking.txt?revision=1.5&view=markup
http://webcvs.freedesktop.org/gstreamer/gstreamer/docs/design/part-segments.txt?revision=1.2&view=markup
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-seek

You might end up doing something like this (in Python syntax):

pipeline.set_state (gst.STATE_PAUSED)
# Wait for state change to happen:
pipeline.get_state ()
success = pipeline.seek (1.0, gst.FORMAT_TIME,
              gst.SEEK_FLAG_FLUSH | gst.SEEK_FLAG_ACCURATE,
              gst.SEEK_TYPE_SET, gst.NSECOND * start_nsecs,
              gst.SEEK_TYPE_SET, gst.NSECOND * end_nsecs)
if success:
    pipeline.set_state (gst.STATE_PLAYING)
else:
    print >> sys.stderr, "Seek failed!"

This plays only the selected range, assuming that the media source
supports seeking and the involved elements work correctly in this
regard.

-- 
Regards,
  René Stadler





More information about the gstreamer-devel mailing list