Playback speed and playbin - do they work together?
Tim Müller
tim at centricular.com
Wed May 7 09:26:12 PDT 2014
On Wed, 2014-05-07 at 19:00 +0300, Alexandru Palade wrote:
Hello Alexandru,
> I'm trying to make a combination of playbin example[1], and playback
> speed example[2]. I want a video to loop indefinitely (using
> about-to-finish signal), but I would like to be able to control the
> speed as well. Here[3]'s my experiment so far. It works, but I do have
> quite a few problems:
>
> 1) when the video is finished and it goes at the beginning, the
> playback speed reverts to the original one. Only after I send a
> send_seek_event by pressing a key it goes back to what is supposed to
> be.
> 2) when the video is finished playing and it needs to start again,
> sometimes, it gets stuck for a few seconds and only then starts
> playing again. Again, calling send_seek_event unfreezes it.
>
>
> The whole day I tried to:
> a) send_seek_event in 'about-to-finish' callback, it appears to fix
> #2, but not #1
> b) listen on the bus for STREAM_START message and call send_seek_event
> then, doesn't work because it can't query the position in at line 28.
> c) listen on the bus for STATE_CHANGED message and try to call
> send_seek_event on different combinations of old state and new state,
> but I always ended up in crashing the program
> d) listen on the bus of ASYNC_DONE message and combined it with
> STREAM_START, still no luck.
>
>
> I'm assuming now that somehow the state of the playbin is important
> when to call that send_seek_event so that playbin can restore the
> playback speed, but I'm out of ideas where to try it. I've read on
> playbin's documentation page that it should have no problem in taking
> gst_element_send_event.
For looping the same file there's a better approach than using the
about-to-finish signal:
- set playbin to PAUSED state
- wait for ASYNC_DONE message on bus
- send a seek for start=0, stop=-1 with flags FLUSH | SEGMENT
- set playbin to PLAYING state
- now you will get a SEGMENT_DONE message on
the bus when the demuxer/parser is finished
with the file (but there's still data buffered,
so playback hasn't finished yet)
- when you get SEGMENT_DONE, do a non-flushing
SEGMENT seek back to start=0,stop=-1
- wait for next SEGMENT_DONE message on the bus
- etc.
You can determine the rate with the seek event.
If you need to change the rate dynamically during playback, you might
want to have a look at the 'frame stepping' API and examples, which let
you do that as well.
> Oh, and I'm in 1.x branch.
Excellent.
Cheers
-Tim
--
Tim Müller, Centricular Ltd - http://www.centricular.com
More information about the gstreamer-devel
mailing list