GStreamer Daemon - Reverse Playback

From RidgeRun Developer Wiki


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.

#!/bin/bash

# Absolute path to the video location
VIDEO=$1

# Graceful cleanup upon CTRL-C
trap "gstd-client pipeline_delete p; exit" SIGHUP SIGINT SIGTERM

# Make sure there is no pipeline with this name already
gstd-client pipeline_delete p

gstd-client pipeline_create p playbin uri=file://$VIDEO

# Pipeline play 
gstd-client pipeline_play p

#Play the video reverse after 5s using seek event with -1.0 rate
#You can change the rate -1<rate<0 to reverse playback in slow-motion  

rate="-1.0"
echo "Setting a negative rate"

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