# GStreamer SDK documentation : Basic tutorial 13: Playback speed This page last changed on Jul 06, 2012 by xartigas. # Goal Fast-forward, reverse-playback and slow-motion are all techniques collectively known as *trick modes* and they all have in common that modify the normal playback rate. This tutorial shows how to achieve these effects and adds frame-stepping into the deal. In particular, it shows: - How to change the playback rate, faster and slower than normal, forward and backwards. - How to advance a video frame-by-frame # Introduction Fast-forward is the technique that plays a media at a speed higher than its normal (intended) speed; whereas slow-motion uses a speed lower than the intended one. Reverse playback does the same thing but backwards, from the end of the stream to the beginning. All these techniques do is change the playback rate, which is a variable equal to 1.0 for normal playback, greater than 1.0 (in absolute value) for fast modes, lower than 1.0 (in absolute value) for slow modes, positive for forward playback and negative for reverse playback. GStreamer provides two mechanisms to change the playback rate: Step Events and Seek Events. Step Events allow skipping a given amount of media besides changing the subsequent playback rate (only to positive values). Seek Events, additionally, allow jumping to any position in the stream and set positive and negative playback rates. In [Basic tutorial 4: Time management](Basic%2Btutorial%2B4%253A%2BTime%2Bmanagement.html) seek events have already been shown, using a helper function to hide their complexity. This tutorial explains a bit more how to use these events. Step Events are a more convenient way of changing the playback rate, due to the reduced number of parameters needed to create them; however, their implementation in GStreamer still needs a bit more polishing so Seek Events are used in this tutorial instead. To use these events, they are created and then passed onto the pipeline, where they propagate upstream until they reach an element that can handle them. If an event is passed onto a bin element like `playbin2`, it will simply feed the event to all its sinks, which will result in multiple seeks being performed. The common approach is to retrieve one of `playbin2`’s sinks through the `video-sink` or `audio-sink` properties and feed the event directly into the sink. Frame stepping is a technique that allows playing a video frame by frame. It is implemented by pausing the pipeline, and then sending Step Events to skip one frame each time. # A trick mode player Copy this code into a text file named `basic-tutorial-13.c`.
This tutorial is included in the SDK since release 2012.7. If you cannot find it in the downloaded code, please install the latest release of the GStreamer SDK. |
Changing the playback rate might only work with local files. If you cannot modify it, try changing the URI passed to |