[gst-devel] help with event-based seeking in MPEG1 video

Ronald Bultje rbultje at ronald.bitfreak.net
Fri Oct 10 00:30:01 CEST 2003

Hi Jeremy,

On Fri, 2003-10-10 at 02:10, Jeremy Gwinnup wrote:
> When I start playback, I the seek bar immediately goes to the right and
> the time counter increases with playback. If I drag the slider during
> playback I get the following message:

Hm, that means it couldn't determine the length, maybe a missing MPEG
header? What's your source? A normal file? A stream (dump)?

Could you retry with HEAD? I've done some work on MPEG in HEAD, I'd be
interested in knowning whether that works any better. If not, please use
(in 0.6.x) --gst-mask=-1 and then grep the output for 'mpeg' (i.e.,
--gst-mask=-1 2>&1 | grep -i mpeg > /tmp/gst.log) and check for any
noteworthy messages there.

> Different question:
> How do/can I determine the length of an MPEG1/2 video in frames? I'm
> trying to use something like this:
> (this code attempts to grab the total length of video in nanoseconds)
> -------------------------------------
> GstPad * fpad =  gst_element_get_pad(filesrc, "src");
> GstFormat fmt = GST_FORMAT_TIME;
> gint64 answer;
> gst_pad_query(fpad, GST_QUERY_TOTAL, &fmt, &answer);
> g_print("clip end is: %lld\n", answer);

The filesrc knows nothing of MPEG, it doesn't even know the concept of
frames. ;). You need to ask the demuxer (mpegdemux) for the length
instead. If you're using spider, see libgstplay
(gst-plugins/gst-libs/gst/play/) for how to do seeks in a spider-created


Ronald Bultje <rbultje at ronald.bitfreak.net>
Linux Video/Multimedia developer

More information about the gstreamer-devel mailing list