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 619434 - playbin: seek in PAUSED state with a custom text-sink
playbin: seek in PAUSED state with a custom text-sink
Status: RESOLVED INCOMPLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.29
Other Linux
: Normal normal
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-23 12:54 UTC by Changwoo Ryu
Modified: 2018-01-25 12:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
seek to 0 & query_position (2.04 KB, text/x-csrc)
2010-05-23 12:54 UTC, Changwoo Ryu
Details
modified text-sink test with suburi (7.43 KB, text/x-csrc)
2010-06-25 03:47 UTC, Changwoo Ryu
Details

Description Changwoo Ryu 2010-05-23 12:54:24 UTC
Created attachment 161787 [details]
seek to 0 & query_position

The attached test (1) sets a custom text-sink which is a bin ("subparse ! appsink"), (2) set the pipeline state to PAUSED, (3) seek to 0, and (4) query position. The query fails as expected when the text-sink is not set. But with the custom text-sink, the pipeline suddenly goes to the end position of the subtitle.

duncan:~/tmp$ tail test.smi
   <SYNC START=13000>
      <P>13000
   <SYNC START=14000>
      <P>14000
   <SYNC START=15000>
      <P>15000
   <SYNC START=100000>
      <P>100000
</BODY>
</SAMI>
duncan:~/tmp$ ./testpause4 file://`pwd`/test.avi file://`pwd`/test.smi 2>/dev/null
position: 0000100000000000
duncan:~/tmp$ 

If I set the render callbacks of the appsink, it receives all parsed subtitles instantly on PAUSED state.
Comment 1 Sebastian Dröge (slomo) 2010-05-24 08:10:57 UTC
Do you get any buffers in the custom text sink after the seeking? Is there any useful output related to seeking with GST_DEBUG=5?

The suburi is not really rate-limited and your sink has to make sure that it's synced to other streams. You will get the complete subtitle file in large chunks and unparsed all at once.
Comment 2 Changwoo Ryu 2010-06-24 03:48:56 UTC
The appsink received all of the buffers after PAUSED.

What should application authors do to make the custom text-sink synced with other streams? Please document it if there are some guidelines on this case.

OTOH I understand the technical aspect that suburi...text-sink pipeline is independent with other audio/video streams. But I think out-of-sync for that reason is not reasonable. Nobody wants to see out-of-sync text subtitles in player. Using several media files in the same playbin2 means those streams are parts of the same media stream consisted with separate files.
Comment 3 Sebastian Dröge (slomo) 2010-06-24 06:12:11 UTC
You have to sync buffers to the clock like every other sink does it. Look at the basesink code or the GstClock documentation to see how you can wait for the clock (gst_clock_new_single_shot_id and gst_clock_id_wait).

If you use a non-syncing audio sink in playbin2, a/v synchronization will get lost too btw. It's the job of the sink to prevent this.
Comment 4 Changwoo Ryu 2010-06-24 06:28:08 UTC
Just clock syncing, is it enough? Then this situation should not happen.

I have not written my own text-sink. I just used an "appsink" (child of GstBaseSink, with default sync=TRUE) as the custom text-sink.
Comment 5 Sebastian Dröge (slomo) 2010-06-24 06:58:10 UTC
Yes, that's enough. Problem in your case is, that your sink accepts unparsed/untimestamped subtitles, e.g. raw sami subtitles. appsink needs timestamped buffers to do the automatic clock-syncing.

Either accept only text/plain and text/x-pango-markup on your appsink's sinkpad (then everything will be timestamped and all that) or do the subtitle parsing and syncing yourself.

An example for the first solution is here: http://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/tests/icles/playbin-text.c
Comment 6 Changwoo Ryu 2010-06-24 08:12:57 UTC
In my first attached code in this bug, I actually created a bin which parses the subtitles and outputs the result to appsink.

	/* make my custom text-sink */
	GstElement *subbin;
	GstElement *appsink;

	subbin = gst_bin_new("subbin");
	subparse = gst_element_factory_make("subparse", NULL);
	appsink = gst_element_factory_make("appsink", NULL);

	gst_bin_add_many(GST_BIN(subbin), subparse, appsink, NULL);
	gst_element_link_many(subparse, appsink, NULL);

	GstPad *ghostpad;
	GstPad *subparsesink;
	subparsesink = gst_element_get_static_pad(subparse, "sink");
	ghostpad = gst_ghost_pad_new("sink", subparsesink);
	g_object_unref(G_OBJECT(subparsesink));
	gst_element_add_pad(subbin, ghostpad);

	g_object_set(G_OBJECT (pipeline), "text-sink", subbin, NULL);

Simple playing works very well with this way, but after several seek/pause/play the subtitle went out-of-sync with audio/video by a few seconds or even a few minutes. Going PAUSED and seeking to 0 is a clear way to reproduce it.

I have not tried the playbin-text.c yet (it seems to require git HEAD version).
Comment 7 Sebastian Dröge (slomo) 2010-06-24 14:02:02 UTC
The text-sink support has improved a bit in GIT compared to 0.10.29, maybe you can check if this helps a bit with your problem? Syncing inside the text-sink works for me with the playbin-text example.
Comment 8 Changwoo Ryu 2010-06-25 03:45:43 UTC
I tried the git HEAD version but there's no difference. With suburi&text-sink settings and after some seek, text subtitles always went out-of-sync. It's quite easily reproducible.

I attached my modified playbin-text.c. It adds (1) suburi setting with argv[2] (2) PAUSE & seek to 0 before playing and (3) some interactive seek feature (',' and '.' keys to RW/FF). Running it makes it go to a wrong position after seeking to 0, and subtitles go out-of-sync after seeking RW/FF.
Comment 9 Changwoo Ryu 2010-06-25 03:47:49 UTC
Created attachment 164578 [details]
modified text-sink test with suburi
Comment 10 Changwoo Ryu 2010-06-25 05:51:41 UTC
It doesn't happen with subtitles embedded in an mkv file.
Comment 11 Sebastian Dröge (slomo) 2013-08-16 11:53:39 UTC
Is this still a problem with 1.0 and latest git master? Can you provide a testcase that reproduces it with 1.0?
Comment 12 Tim-Philipp Müller 2018-01-25 12:37:49 UTC
Closing this bug report as no further information has been provided. Please feel free to reopen this bug report if you can provide the information that was asked for in a previous comment.
Thanks!