GStreamer Daemon - Seek: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 34: Line 34:
== Example Application ==
== 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.
A very useful application of the seek event is when a video is needed to playback in a interval, for severals seconds. This example shows how to set the start time and the end time of the playback, the seek event takes the time in nanoseconds, for this example the playback start at 5s and ends in 10s.  
 


<br>&rArr; ''Gstd Commands:''
<br>&rArr; ''Gstd Commands:''
<syntaxhighlight lang="bash" line="line" style="background-color:lavender">
<syntaxhighlight lang="bash" line="line" style="background-color:lavender">
# Create the pipeline and start recording
# Create the pipeline  
pipeline_create p1 v4l2src ! x264enc ! qtmux ! filesink location=/mnt/recording.mp4
pipeline_create p1 playbin uri=file:///tmp/video.mp4
 
# Play the pipeline
pipeline_play p1
pipeline_play p1


# ... wait until recording is no longer required
# Send the seek event. Play the pipeline from the second 5 to 10
 
event_seek p1 1.0 3 1 1 5000000000 1 10000000000
# 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>
</syntaxhighlight>




}}
}}