GStreamer Daemon - Slow Motion: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
mNo edit summary
 
(16 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Gstd-1.0 Page|[[Gstd-1.0 - MP4 Video Recording|MP4 Video Recording]]|[[Gstd-1.0 - Reverse Playback|Reverse Playback]]|
{{GStreamer Daemon/Head | previous=New Clock | next=Reverse Playback}}
 
For the slow motion examples we will use the seek gstd event, with that event we can control the rate, beginning and ending of the pipeline stream.


For the slow motion example we will use the seek gstd event, with that event we can control the video speed using the rate property, also we can control the beginning and ending of the video pipeline stream.
To get the playback in slow motion, the rate of the seek event should be in the following interval:
0 < rate < 1


== Example ==
== Example ==
Line 12: Line 14:


# Absolute path to the video location
# Absolute path to the video location
VIDEO=$video.avi
VIDEO=$1


# Graceful cleanup upon CTRL-C
# Graceful cleanup upon CTRL-C
Line 22: Line 24:
gstd-client pipeline_create p playbin uri=file://$VIDEO
gstd-client pipeline_create p playbin uri=file://$VIDEO


# Listen to the EOS messages
# Pipeline play
gstd-client bus_filter p eos
gstd-client pipeline_play p
 
#Play the video from the second 5s to the second 10s in slow-motion
#using seek event with 0.5 rate


gstd-client pipeline_play p
sleep 5
gstd-client event_seek p 0.5 3 1 1 5000000000 1 10000000000


# Wait for the message to perform seek
while true; do
    gstd-client bus_read p
    gstd-client event_seek p 1.0
done
</syntaxhighlight>
</syntaxhighlight>


To run the script you will need an existing video. You may use the [[Gstd-1.0 - MP4 Video Recording| video recording simple example]] to quickly use Gstd-1.0 to record one. To run the Gapless script type
To run the script you will need an existing video. You may use the [[Gstd-1.0 - MP4 Video Recording| video recording simple example]] to quickly use Gstd-1.0 to record one. To run the Slow-motion script type


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
./simple-gapless-playback.sh /tmp/video.mp4
./simple-slow-motion.sh /tmp/video.mp4
</syntaxhighlight>
</syntaxhighlight>


}}
{{GStreamer Daemon/Foot | previous=New Clock | next=Reverse Playback}}

Latest revision as of 12:39, 3 April 2020



Previous: New Clock Index Next: Reverse Playback




For the slow motion example we will use the seek gstd event, with that event we can control the video speed using the rate property, also we can control the beginning and ending of the video pipeline stream. To get the playback in slow motion, the rate of the seek event should be in the following interval:

0 < rate < 1 

Example

The following example is a bash script that demonstrates the simple slow motion 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 from the second 5s to the second 10s in slow-motion 
#using seek event with 0.5 rate 

sleep 5
gstd-client event_seek p 0.5 3 1 1 5000000000 1 10000000000

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 Slow-motion script type

./simple-slow-motion.sh /tmp/video.mp4


Previous: New Clock Index Next: Reverse Playback