Seeking forward is not working
Rossana Guerra
guerra.rossana at gmail.com
Sat Feb 25 15:26:57 PST 2012
Hi Tim and everyone, I read in the mailing list that before seeeking is
necessary for waiting for the pipeline to preroll, since the pipeline
changes its state asynchronically.
I use the "get_bus_timed_pop_filtered" function before doing the event
seeking as the code below shows.
Now it works as expected.
Is there a better manner to do this? In the seeking examples I saw this
function is barely mentioned, of the contrary seeking event is almost a
fashion template procedure.
I appreciate any concepts to clarify this issue. Thanks so much.
Rossana
// handler error routine EOS, ERROR, etc
// global variable definitions
gint main (gint argc, char *argv[])
{
GMainLoop *loop = 0;
GstBus *bus = 0;
/* set up */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
play = gst_element_factory_make ("playbin2", "play");
bus = gst_pipeline_get_bus (GST_PIPELINE (play));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
g_object_set (G_OBJECT (play), "uri",playlist[0], NULL);
g_object_set (G_OBJECT (play), "suburi",playsubt[0], NULL);
gst_element_set_state (play, GST_STATE_PLAYING);
GstMessage *msg2 = 0;
msg2 = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (play),
GST_CLOCK_TIME_NONE, GST_MESSAGE_ASYNC_DONE);
if (GST_MESSAGE_TYPE (msg2) == GST_MESSAGE_ERROR) {
return 0;
}
gst_message_unref (msg2);
if (!gst_element_seek (GST_ELEMENT(play), 1.0, GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET, 15*GST_SECOND,
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
g_print ("Seek failed!\n");}
else
g_print ("Seek OK!\n");
/* now run */
g_main_loop_run (loop);
/* also clean up */
gst_element_set_state (play, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (play));
return 0;
}
2012/2/25 Rossana Guerra <guerra.rossana at gmail.com>
> Hi Tim, the seeking is not working, according to the code it is expected
> it reaches the position that corresponds to the 15 seconds of video and it
> doesn't. It begins to play from the begining as if no seeking wasn't
> applied.
> According to this code, the seeking it's done (it prints "seek OK")
>
> // gst int and so on
> //here I create the pipeline and I attach the callback event
>
>
> gst_element_set_state (play, GST_STATE_PLAYING);
>
> gst_element_set_state (play, GST_STATE_PAUSED);
> if (!gst_element_seek (GST_ELEMENT(play), 1.0, GST_FORMAT_TIME,
> GST_SEEK_FLAG_FLUSH,
> GST_SEEK_TYPE_SET, 15*GST_SECOND,
> GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
> g_print ("Seek failed!\n");}
> else
> g_print ("Seek OK!\n")
>
> Thanks, cheers
>
> Rossana
>
>
> 2012/2/25 Tim-Philipp Müller <t.i.m at zen.co.uk>
>
>> On Sat, 2012-02-25 at 05:08 -0200, Rossana Guerra wrote:
>>
>> > I need it to do a seek at the start of the 'player'.
>> > This is the code, according to the message, the seek is done, but not
>> > in the place it should be. I want it to start at 15 seconds from its
>> > begining
>> >
>> > ....
>> > g_print ("Seek OK!\n"); // it seems it does the seek, but it
>> > doesn't it plays the video from the begining.
>> >
>> > What is wrong?, I see these line in many examples.
>>
>> What is it that actually happens insteaad then? It's not quite clear to
>> me how it fails.
>>
>> Cheers
>> -Tim
>>
>>
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120225/e4acd2e5/attachment.html>
More information about the gstreamer-devel
mailing list