Video seeking. Best practices

Nicolas Dufresne nicolas at
Sat Feb 15 02:23:54 UTC 2020

Le ven. 14 févr. 2020 14 h 15, Ilya Aleshkov <ilya.aleshkov at> a
écrit :

> Hi,
> I'd like to make my seeking process as interactive as possible.
> In general everything works. I'm able to preview and record streams from
> webcams from my C++ code.
> Recording pipeline equivalent looks like:
> gst-launch-1.0 -e v4l2src device=/dev/video0 ! "video/x-raw, ..." !
> videoconvert ! x264enc ! matroskamux ! filesink location=filename.mkv
> or (using NVIDIA's hardware-accelerated NVENC encoder API)
> gst-launch-1.0 -e v4l2src device=/dev/video0 ! "video/x-raw, ..." !
> videoconvert ! nvh264enc ! h264parse ! matroskamux ! filesink
> location=filename.mkv
> It's not hard to playback my recordings with playbin and seek:
> gst_element_get_state(m_pipeline, nullptr, nullptr, GST_CLOCK_TIME_NONE);
> // This trick make seeking much more interactive
> gst_element_seek(m_pipeline, 1.0, GST_FORMAT_TIME,
>                   (GstSeekFlags) (GST_SEEK_FLAG_FLUSH |
>                   GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_NONE,
> But even using NVDEC I'm not happy with performance. It's not bad at all,
> but not smartphone-like smooth. What can I do to dramatically improve it?

The trick you use make sense, at least is simple. Each time you do a
flushing seek, there is a lost state, so you end up ensuring that last seek
is completed before issuing next one. You could do the same by using bus
messages, that would allow for better compression of the seek location.

My usual approach is to have a state, so when user grabs the seek handle, I
enable scrubbing mode. In this mode I issue a seek each time the previous
seek completes, I usually don't select accurate seek for speed. Then when
the seek handle is released, I issue a flushing seek immediately with
accurate flag this time.

That being said, GStreamer often lack a bit of optimization in term of seek
performance, contribution are welcome.

> Environment: Ubuntu 19.10 / Intel Core i7-2600 / GeForce GTX 1050 Ti / SSD
> Thanks,
> Ilya
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list