Tutorial 3 – Simple DB Export

Tutorial 2 – Getting Camera Information

From the previous tutorial, we left off with the ability to get information about cameras in the system.

In this tutorial, we’ll actually export to Ocularis Database (DB) format from them.

The Ocularis DB Export is a proprietary export format that can be used in the Ocularis Client.

First, add the following Reference to your .NET application from the SDK folder:

  • AxHeimdallLib.dll

Also, add the following system References to your .NET application:

  • System.Windows.Forms

The main component that we’ll be dealing with throughout this tutorial is AxAuga. AxAuga is the streaming/transcoding/exporting part of the SDK. It actually has quite a bit of functionality, but in this tutorial, we’ll focus on its ability to export video.

First off, we need to create an instance of AxAuga:

AxAuga is an ActiveX Control that can be used as a Control for a Windows Form. So, the next step will be to create a Windows Form for the AxAuga Control to be hosted in:

This Windows Form will be hidden and used for its Window Handle as well as its Windows message pump integration. Here’s how we’ll hide the initial display of the Form:

Now that we have a Form and a Control, let’s do some setup once the Form’s Shown event is fired. It’s important to note that all exporting work with an AxAuga instance must be done after calling Application.Run as we’ll see later. Here’s the AxAuga initialization code during Shown:

On Shown, we add the AxAuga instance as a Control to the video Form. This makes it so AxAuga is included to receive Windows messages. Then we call Init on the AxAuga instance to set timer hooks into the Form’s Window message loop as well as set it up for exporting. Init takes one argument, which is the monitor ID, to display on for rendering. In our case, we’ll give it an empty string because we will not be using AxAuga for display.

Now that we have added the Control and Init’d it, we need to give AxAuga the privileges to stream, like so:

SetCameraIDispatch takes the ID of the camera, and the camera’s IDispatch interface. This gives AxAuga direct access to the camera for privileges to stream.

Once we have streaming privileges, let’s setup the connection to the NVR, which is associated with our camera. To export, AxAuga must be connected directly to the NVR:

OCCamera’s GetDynamicLiveURL will initiate a connection to the associated NVR and will return a valid URL when that connection has been made; we wait until it’s non-null before continuing.

After we establish a connection to the NVR that we’ll export from, let’s start the export:

AxAuga’s StartDBExport method takes the following: a live URL to export from, an unused meta data string, a file name to place the DB files, the year, month, day, hour, minute, second, millisecond start and stop times ( all in UTC ), a password string to protect the DB file, and a bool indicating if the data needs to be encrypted.

AxAuga’s StartDBExport starts the DB export.

At the end of the Shown event handler:

Setting the Visible property of the Form to false makes sure that the Form won’t be shown.

We’ve done everything that needs to be done during the Form Shown. During Form Closing we need to do some cleanup so that we don’t leak AxAuga’s resources:

When the Closing event is sent to the Form we call AxAuga’s Shutdown method on the instance. Shutdown frees all of the resources we needed to stream and export the video.

The final thing to do is to run our Form:

Screenshots of the final program:

That’s about it, so now we can export to Ocularis DB format for a video segment.

Tutorial 4 – DB Export Status