GStreamer Daemon - EOS

From RidgeRun Developer Wiki



Previous: Receiving Messages from the Bus Index Next: Seek




This wiki shows how to send an EOS (End of Stream) event to a given pipeline. The EOS event is useful for notifying the elements in a pipeline that no further buffers are expected and they can wrap up any processing required to properly close the stream. For example, the MP4 muxer will update the file length value in the MP4 headers (located at the beginning of the file) when an EOS event is received. If such an event isn't received, the recording will not be playable. When all elements have processed the EOS, an EOS message will be posted to the pipeline bus. Applications may listen to the bus in order to wait for this message.

Sending an EOS event

A new EOS event is sent to a pipeline using the command shown below. The EOS event takes no argument.

 event_eos pipeline 
     Creates a new EOS event and sends it to pipeline.

For example:
Gstd Commands:

pipeline_create p1 videotestsrc ! autovideosink
pipeline_play p1
event_eos p1

will respectively

  1. Create a pipeline p1
  2. Put it to playing
  3. Send an EOS event to it

The event_eos command will typically fail for any of the following:

  • No pipeline was given
  • The given pipeline doesn't exist

Alternatively, a pipeline can be created using the low level CRUD syntax:
Gstd Commands:

create /pipelines/p1/event eos

Example Application

A very useful application of the EOS event is when used along with the EOS bus message to notify the application when the stream is finally closed. Consider, for example, an HD video recording where a high amount of data is being written to the file system. If you stop the pipeline after a long-running time, it's likely that the tear down will take some time while the data is fully written to its destination. If the application needs to make use of the recording after stopping the pipeline, it would need to wait until the stream is actually closed; otherwise the file may result in corrupted. The EOS event and message can indicate when the write-back is done.


Gstd Commands:

# Create the pipeline and start recording
pipeline_create p1 v4l2src ! x264enc ! qtmux ! filesink location=/mnt/recording.mp4
pipeline_play p1

# ... wait until recording is no longer required

# Send the EOS
event_eos p1
# Wait for the stream to stop
bus_filter p1 eos
bus_read p1

# Finally stop the pipe
pipeline_stop p1

API Summary

High Level Command Low Level CRUD Description
event_eos <pipe> create /pipelines/<name>/event_eos Sends a EOS event to an element



Previous: Receiving Messages from the Bus Index Next: Seek