After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761439 - basesink: Backward step operations fail and may lead to negative position value in Totem
basesink: Backward step operations fail and may lead to negative position val...
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.11.x
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-02-02 00:06 UTC by Cosimo Cecchi
Modified: 2018-11-03 12:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot (322.23 KB, image/jpeg)
2016-02-02 00:07 UTC, Cosimo Cecchi
  Details
log (63.83 KB, text/plain)
2016-02-03 18:48 UTC, Cosimo Cecchi
  Details
fix wrong time when stepping backwards (942 bytes, patch)
2017-05-16 10:36 UTC, Vincent Penquerc'h
none Details | Review
with unit test (10.50 KB, patch)
2017-05-24 15:19 UTC, Vincent Penquerc'h
none Details | Review

Description Cosimo Cecchi 2016-02-02 00:06:32 UTC
To reproduce:
- start playing a video
- (optional to make bug more obvious) seek in the middle
- hold comma

Notice that the state of the timeline becomes completely inconsistent.
See attached screenshot of Big Buck Bunny, but this seems reproducible with any video.
Comment 1 Cosimo Cecchi 2016-02-02 00:07:12 UTC
Created attachment 320247 [details]
screenshot
Comment 2 Bastien Nocera 2016-02-03 14:55:00 UTC
I'll assume this is easily reproduceable with the "seek" test program in GStreamer, and is possibly container specific.
Comment 3 Nicolas Dufresne (ndufresne) 2016-02-03 15:30:53 UTC
We'll definitely need more research then that.
Comment 4 Bastien Nocera 2016-02-03 17:09:10 UTC
Cosimo, can you please try to grab the GStreamer debug log as per:
https://wiki.gnome.org/Apps/Videos/BugReporting
?
Comment 5 Bastien Nocera 2016-02-03 17:10:10 UTC
This is the code that does the stepping. Nothing too complicated really:
https://git.gnome.org/browse/totem/tree/src/backend/bacon-video-widget.c#n4195
Comment 6 Cosimo Cecchi 2016-02-03 18:48:59 UTC
Created attachment 320387 [details]
log
Comment 7 Nicolas Dufresne (ndufresne) 2016-02-03 19:25:41 UTC
Just for clarity, is that only with Theora/Ogg ?
Comment 8 Cosimo Cecchi 2016-02-03 19:29:55 UTC
Nicolas, no I can reproduce also with an MP4 container with H.264 video.
Comment 9 Nicolas Dufresne (ndufresne) 2016-02-03 19:49:34 UTC
I confirm, looks bad. So backward stepping seems to break apart. I don't see anything wrong in totem, I do see bunch of assertions:

(totem:22123): GStreamer-CRITICAL **: gst_segment_do_seek: assertion 'start <= stop' failed

A small unrelated note though, if you step back (and it didn't fail like this ^, totem stays in backward playback mode, not sure this is the expected behaviour, but who knows, I didn't know totem was exposing this kind of stuff).
Comment 10 Sebastian Dröge (slomo) 2016-02-03 21:23:14 UTC
You can also use gst-plugins-base/tests/examples/playback for reproducing these kind of things btw, it might give more control over what exactly is happening than totem.

For the backward playback, to do backwards stepping you need to first issue a negative-rate seek. Stepping can only happen in the current playback direction.


Also it should be completely unrelated to container format and codecs. Stepping is handled completely in basesink (except for the seeks to change playback direction).
Comment 11 Nicolas Dufresne (ndufresne) 2016-02-03 22:15:03 UTC
(In reply to Sebastian Dröge (slomo) from comment #10)
> You can also use gst-plugins-base/tests/examples/playback for reproducing
> these kind of things btw, it might give more control over what exactly is
> happening than totem.
> 
> For the backward playback, to do backwards stepping you need to first issue
> a negative-rate seek. Stepping can only happen in the current playback
> direction.

Totem does that, I have reviewed. It does not wait for the preroll to complete, so might be a bit racy, but the behaviour indicate a bug in any case. I'm surprised though, as I thought one could flip the direction without having to seek to a start/stop position (passing NONE as positions, seek still need to be flushing I suppose).
Comment 12 Sebastian Dröge (slomo) 2016-02-03 23:41:31 UTC
Yes, seeking with start=stop=NONE should be possible (separate bugs otherwise). But you definitely need to seek. You don't necessarily need to FLUSH seek though, it just takes longer for the direction change to take place otherwise.

So yes there's definitely a bug here, I just mean that the playback example could be useful for debugging here as it gives more control than totem.
Comment 13 Cosimo Cecchi 2017-04-04 02:09:50 UTC
This is still 100% reproducible on current Fedora 26 with GStreamer 1.11.2.
Comment 14 Vincent Penquerc'h 2017-05-12 15:40:08 UTC
I think this looks wrong:

5890	    GST_DEBUG ("Setting playback direction to %s at %"G_GINT64_FORMAT"", DIRECTION_STR, cur);
5891	    event = gst_event_new_seek (target_rate,
5892					GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
5893					GST_SEEK_TYPE_SET, forward ? cur : G_GINT64_CONSTANT (0),
5894					GST_SEEK_TYPE_SET, forward ? G_GINT64_CONSTANT (0) : cur);
5895	    if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
5896	      GST_WARNING ("Failed to set playback direction to %s", DIRECTION_STR);
5897	    } else {
5898	      gst_element_get_state (bvw->priv->play, NULL, NULL, GST_CLOCK_TIME_NONE);
5899	      bvw->priv->rate = target_rate;

In the seek event, if we're going forward, both start and stop are set, and the segment is set from cur to 0. Should it not be from cur to something unset ?
Comment 15 Bastien Nocera 2017-05-16 09:52:27 UTC
(In reply to Vincent Penquerc'h from comment #14)
> I think this looks wrong:
> 
> 5890	    GST_DEBUG ("Setting playback direction to %s at
> %"G_GINT64_FORMAT"", DIRECTION_STR, cur);
> 5891	    event = gst_event_new_seek (target_rate,
> 5892					GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
> 5893					GST_SEEK_TYPE_SET, forward ? cur : G_GINT64_CONSTANT (0),
> 5894					GST_SEEK_TYPE_SET, forward ? G_GINT64_CONSTANT (0) : cur);
> 5895	    if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
> 5896	      GST_WARNING ("Failed to set playback direction to %s",
> DIRECTION_STR);
> 5897	    } else {
> 5898	      gst_element_get_state (bvw->priv->play, NULL, NULL,
> GST_CLOCK_TIME_NONE);
> 5899	      bvw->priv->rate = target_rate;
> 
> In the seek event, if we're going forward, both start and stop are set, and
> the segment is set from cur to 0. Should it not be from cur to something
> unset ?

You mean passing -1 instead of 0 as the "stop" argument? That's what it throws:
(totem:21224): GStreamer-CRITICAL **: gst_segment_position_from_running_time: assertion 'segment->format == format' failed

The documentation isn't exactly great explaining what the stop value is, but it says:
"
For negative rates, playback will start from the newly configured stop position (if any). If the stop position is updated, it must be different from -1 (GST_CLOCK_TIME_NONE) for negative rates.
"

So 0 looks correct.
Comment 16 Vincent Penquerc'h 2017-05-16 10:08:44 UTC
I mean passing GST_SEEK_TYPE_NONE instead of 0, in the forward case (so positive rate). AFAICT, the forward case in the code above creates a seek from current to 0. I guess I'm missing something here, I'm just not sure what.
Comment 17 Vincent Penquerc'h 2017-05-16 10:36:55 UTC
Created attachment 351960 [details] [review]
fix wrong time when stepping backwards

Tracked down.
Comment 18 Sebastian Dröge (slomo) 2017-05-16 11:54:07 UTC
Comment on attachment 351960 [details] [review]
fix wrong time when stepping backwards

Can you please make a unit test for this? It seems to make sense but it might break again if you don't write a test :)
Comment 19 Vincent Penquerc'h 2017-05-24 15:19:59 UTC
Created attachment 352509 [details] [review]
with unit test
Comment 20 Tim-Philipp Müller 2017-07-11 21:10:01 UTC
With patch and unit test.
Comment 21 GStreamer system administrator 2018-11-03 12:32:48 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/154.