GStreamer Daemon - Gapless Playback

From RidgeRun Developer Connection
Jump to: navigation, search


Previous: Simple Examples Index Next: MP4 Video Recording




The Gapless Playback example will run a video from start to end sequentially in an infinite loop. To do so, it will wait for the file playback to finish before rewinding to the beginning of the file and restarting playback. The end of the playback is detected by polling the pipeline bus for the End Of Stream (EOS) message, which is posted by the Filesrc element when all the content has been read. The rewinding is done by sending a Seek event to the pipeline, which effectively restarts the pipeline.

Example for Gapless Playback

The following example is a bash script that demonstrates the simple gapless playback.

 1 #!/bin/bash
 2 
 3 # Absolute path to the video location
 4 VIDEO=$1
 5 
 6 # Graceful cleanup upon CTRL-C
 7 trap "gstd-client pipeline_delete p; exit" SIGHUP SIGINT SIGTERM
 8 
 9 # Make sure there is no pipeline with this name already
10 gstd-client pipeline_delete p
11 
12 gstd-client pipeline_create p playbin uri=file://$VIDEO
13 
14 # Listen to the EOS messages
15 gstd-client bus_filter p eos
16 
17 gstd-client pipeline_play p
18 
19 # Wait for the message to perform seek
20 while true; do
21     gstd-client bus_read p
22     gstd-client event_seek p 1.0
23 done

To run the script you will need an existing video. You may use the video recording simple example to quickly use Gstd-1.0 to record one. To run the Gapless script type

./simple-gapless-playback.sh /tmp/video.mp4



Previous: Simple Examples Index Next: MP4 Video Recording