GStreamer Daemon - EOS: Difference between revisions
(Created page with "{{Gstd-1.0 Page |Sending Events|Seek| This wiki shows how to send an [https://gstreamer.freedesktop.org/data/doc/gstreamer/he...") |
No edit summary |
||
Line 4: | Line 4: | ||
== Sending an EOS event == | == Sending an EOS event == | ||
== Example | A new EOS event is sent to a pipeline using the command shown below. The EOS event takes no argument. | ||
<b>event_eos <i>pipeline</i> </b> | |||
Creates a new EOS event and sends it to <i>pipeline</i>. | |||
For example: | |||
<br>⇒ ''Gstd Commands:'' | |||
<syntaxhighlight lang="bash" line="line" style="background-color:lavender"> | |||
pipeline_create p1 videotestsrc ! autovideosink | |||
pipeline_play p1 | |||
event_eos p1 | |||
</syntaxhighlight> | |||
will respectively | |||
# Create a pipeline ''p1'' | |||
# Put it to playing | |||
# 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 [[Gstd-1.0 - Low Level Implementation for Applicaiton|low level CRUD syntax]]: | |||
<br>⇒ ''Gstd Commands:'' | |||
<syntaxhighlight lang="bash" line="line" style="background-color:lavender"> | |||
create /pipelines/p1/event eos | |||
</syntaxhighlight> | |||
== Example Application == | |||
A very useful application of the EOS event is when used along with [[Gstd-1.0 - Receiving Messages from the Bus|the EOS bus message]] to notify the application when the stream is finally closed. Consider, for example, an HD video recording where 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 corrupted. The EOS event and message can indicate when the write back is done. | |||
<br>⇒ ''Gstd Commands:'' | |||
<syntaxhighlight lang="bash" line="line" style="background-color:lavender"> | |||
# 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 | |||
</syntaxhighlight> | |||
}} | }} |
Revision as of 22:57, 23 May 2017
← Sending Events |
⌂ Home |
→ 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 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
- Create a pipeline p1
- Put it to playing
- 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 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 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
← Sending Events |
⌂ Home |
→ Seek |
- GStreamer Daemon Basics
- Building GStreamer Daemon
- Quick Start Guide
- Interacting with Pipelines
- Modifying Element Properties
- Sending Events
- Receiving Messages from the Bus
- Receiving Signals
- Enabling the Debug Subsystem
- Low-level Implementation for Applications
- Response Format
- API Reference
- Simple Examples
- Advanced Examples
- Troubleshooting
- Releases
- Licensing
- FAQ
- Contact Us