To EOS or not to EOS?

Tim-Philipp Müller t.i.m at zen.co.uk
Wed Apr 3 06:33:06 PDT 2013


On Wed, 2013-04-03 at 06:11 -0700, Wes Miller wrote:

> For a running pipeline that I want to stop, is there any advantage to sending
> it an EOS then setting its state  to GST_STATE_NULL, or can I just go to the
> GST_STATE_NULL state without side effects?
> 
> What if the pipeline is still in GST_STATE_CHANGE_ASYNC?

As always, it depends on the pipeline.

A playback pipeline you can just set to GST_STATE_NULL no matter what
the current state is (ASYNC is not a state btw, but a state change
return), you just want to shut it down asap.

With a recording pipeline where there's a muxer involved and you write
to a file it's a bit different. Here you want to send the EOS event,
then *wait* until you get an EOS message on the pipeline bus, and only
then set the pipeline state to NULL. This makes sure that the muxer
finalises the file properly, and all pending data gets written correctly
to the file. It depends on the muxer/format in question whether just
shutting down the pipeline is okay or not. For some formats (mpeg-ts,
mpeg-ps, ogg) it's fine to just stop, the already-written data will
usually be sufficient. For most other formats (avi, quicktime/mp4,
matroska, flac) you need to shut the muxer/filesink down cleanly so the
headers can be written and/or finalised, and the file will be corrupted
if you don't do that.

Cheers
 -Tim



More information about the gstreamer-devel mailing list