GStreamer Daemon - Reverse Playback

From RidgeRun Developer Connection
Jump to: navigation, search


Previous: Slow Motion Index Next: Monitor pipeline errors




For the reverse playback example, we will use the seek gstd event, with that event we can control the video playback using the rate property. To get the reverse playback, the rate of the seek event should be negative as follows:

 rate < 0 

For a slow-motion reverse playback, the rate has to be in the interval:

 -1 < rate < 0 

Example

The following example is a bash script that demonstrates the simple reverse 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 # Pipeline play 
15 gstd-client pipeline_play p
16 
17 #Play the video reverse after 5s using seek event with -1.0 rate
18 #You can change the rate -1<rate<0 to reverse playback in slow-motion  
19 
20 rate="-1.0"
21 echo "Setting a negative rate"
22 
23 gstd-client "event_seek p $rate"

To run the script you will need an existing video. You may use the video recording simple example to quickly use GStreamer Daemon to record one. To run the reverse playback script type

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


Previous: Slow Motion Index Next: Monitor pipeline errors