Loop a file using playbin without artefacts
Nicolas Dufresne
nicolas.dufresne at collabora.com
Thu May 21 11:07:47 PDT 2015
The following seems a bit awkward to me (I might be missing some
details). This is how I do it, and how I think it's supposed to work.
1. Save and set the prerolled state to FALSE
2. Set your pipeline to playing state
3. When you receive the async-done message
* If not prerolled yet
3.1 send a flusing segment seek, with the start/stop you want
3.2 set the prerolled state to true
4. When you receive the segment done message
* Send a non-flushing seek, with same start/stop to loop
Remember that a flushing seek will lead to an async done message.
Ignoring this will lead to an infinite seek loop.
Nicolas
p.s. This method may display the first frame of the media. This can be
worked around by disabling presentation of the preroll buffer in your
display sink. Additionally, setting to paused at 1, and to playing at
3.3, will ensure there is no race.
Le Thursday 21 May 2015 à 20:54 +0300, Nikos Chantziaras a écrit :
> On 21/05/15 19:20, Arnaud Loonstra wrote:
> > On 2015-05-21 18:13, Nikos Chantziaras wrote:
> > > On 21/05/15 19:02, Arnaud Loonstra wrote:
> > > > Hi all,
> > > >
> > > > I'm doing a simple looping of a h264 file (raspbian provided
> > > > test.h264
> > > > for example)
> > > >
> > > > When I receive a SEGMENT_DONE message on the bus I seek to the
> > > > beginning:
> > > >
> > > > flags = Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT |
> > > > Gst.SeekFlags.SEGMENT
> > > > self.playbin.seek(1.0, Gst.Format.TIME, flags,
> > > > Gst.SeekType.SET, 0,
> > > > Gst.SeekType.SET, -1)
> > >
> > >
> > > Try this instead:
> > >
> > > gst_element_seek_simple(pipeline, GST_FORMAT_TIME,
> > > GST_SEEK_FLAG_SEGMENT, 0);
> > >
> >
> > In python that would be
> >
> > self.playbin.seek_simple(Gst.Format.TIME, Gst.SeekFlags.SEGMENT, 0)
> >
> > But that just makes the video freeze at the end frame giving
> > nonstop
> > SEGMENT_DONE messages.
> > If I add a FLUSH it does loop but with the artefacts.
>
> I tried many approaches, and the way I ended up with that works very
> reliably is to first put the pipeline into the playing state first,
> wait
> for the transition to complete, and then do a seek to the end:
>
> gst_element_set_state(pipeline, GST_STATE_PLAYING);
> // Wait for the state change to complete.
> gst_element_get_state(pipeline, 0, 0, GST_CLOCK_TIME_NONE);
> // Seek to the end.
> gst_element_seek(pipeline, 1.0, GST_FORMAT_TIME,
> GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT,
> GST_SEEK_TYPE_END, 0, GST_SEEK_TYPE_NONE,
> GST_CLOCK_TIME_NONE);
>
> The above is in my play() routine. In the event handler for
> GST_MESSAGE_SEGMENT_DONE, I simply do:
>
> gst_element_seek_simple(pipeline, GST_FORMAT_TIME,
> GST_SEEK_FLAG_SEGMENT, 0);
>
> This works extremely well for all videos (except for segmented MP4
> files
> intended for online streaming; a known GStreamer limitation.)
>
> Are you really sure the artifacts you're seeing aren't actually part
> of
> the video? Can you post the video somewhere to see if it's
> reproducible
> by others? Also, have you tried other videos? Do you get the problem
> with other videos as well?
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20150521/5b3fae3c/attachment-0001.sig>
More information about the gstreamer-devel
mailing list