Tutorial 4 – Playback Control

Requirements:
Tutorial 3 – Simple Video Processing


In the previous tutorial we learned how to setup a simple live video processor.

In this tutorial we’ll learn how to use the same processor to print out information about video in the past using playback controls.

First, if you recall there was a set of video hook command we were using, let’s extend that to include the commands for playback:

Let’s see how these new commands: BROWSE_START, BROWSE_STOP, BROWSE_NEXT, BROWSE_PREVIOUS, and BROWSE_GOTO work.

To start receiving playback video frames we’ll start by switching into browse mode:

Switching into browse/playback mode is as simple as stopping the live stream with STOP_LIVE and then using the BROWSE_START command. The BROWSE_START command takes no additional arguments and puts us into browse mode so that other browse commands are enabled.

Next, we’ll seek into the past using the BROWSE_GOTO command:

The BROWSE_GOTO video hooks command takes a time in milliseconds since epoch or 1970/1/1 UTC. The timestamp is broken up into two 32bit parts, the high bits and low bits. In our example above, we calculate 10 minutes in the past, make the required conversions, and split the timestamp as arguments to the BROWSE_GOTO command. Once seek’d into the proper position, we’ll receive the first frame in our callback and the stream will stay paused at that position in time.

With our video seek’d to a spot let’s some frame stepping:

The BROWSE_NEXT video hooks command takes no arguments and advances the video stream forward by one frame. The frame that we advance to will be sent to our callback and the stream will stay paused at that position in time.

Now, let’s frame step backward:

The BROWSE_PREVIOUS video hooks command takes no arguments and advances the video stream backward by one frame. The frame that we advance to will be sent to our callback and the stream will stay paused at that position in time.

Finally, to take ourselves out of browse mode:

The BROWSE_PREVIOUS video hooks command takes no arguments and take us out of browse mode. This command should always be used when exiting browse mode to ensure resources aren’t leaked.

Screenshot of the final program:
Series-2-Tutorial-4

That concludes this tutorial. You can now make use of playback video when processing video.