ONVIF for ZoneMinder – Streaming

The Media service

I wanted some quick wins therefore I focused on getting the camera to work. I decided the generic message parsing stuff would have to wait.

With the address I got previously I called the ONVIF Device Management web service method GetServices.I received this response: (I removed all XML header information and information on all services but Media.)

    <trt:Capabilities SnapshotUri="true" Rotation="false">
      <trt:ProfileCapabilities MaximumNumberOfProfiles="10"></trt:ProfileCapabilities>
      <trt:StreamingCapabilities RTPMulticast="true" RTP_TCP="true" 
        RTP_RTSP_TCP="true" NonAggregateControl="false">

Among some capability information I got the address for the next service to call:

I wanted to call these functions:

  • GetProfiles () – returns a list of Media Profiles describing settings such as video resultion, audio quality
  • GetStreamUri (Profile, StreamType) – returns a URI for the media feed

I would be able to enter the properties and URI of the video feed in ZoneMinder and get a first view of the camera.

Eventually this sequence of functions needed to be integrated into ZoneMinder. My goal was to automatically probe for ONVIF cameras and their settings. And then create a new monitor based on these settings.


The first response I got  was “The action requested requires authorization and the sender is not authorized.” Therefore I implemented a SecuritySerializer module that enriches all outgoing messages with a WS-Security UsernameToken header.

First view

For GetProfiles() I got a response with two pre-configured profiles. One of which I pasted below.

By the way – ONVIF also defines messages to change these settings and create new profiles. However, it seems ZoneMinder has no UI for this functionality. You need to configure your camera with the program that comes with your camera and then enter its settings in the ZoneMinder monitor definition.

<trt:Profiles token="Profile_1" fixed="true"><tt:Name>mainStream</tt:Name>
<tt:VideoSourceConfiguration token="VideoSourceToken"><tt:Name>VideoSourceConfig</tt:Name>
<tt:Bounds x="0" y="0" width="2048" height="1536"></tt:Bounds>
<tt:VideoEncoderConfiguration token="VideoEncoderToken_1"><tt:Name>VideoEncoder_1</tt:Name>
<tt:VideoAnalyticsConfiguration token="VideoAnalyticsToken"><tt:Name>VideoAnalyticsName</tt:Name>
<tt:AnalyticsEngineConfiguration><tt:AnalyticsModule Name="MyCellMotionModule" Type="tt:CellMotionEngine"><tt:Parameters><tt:SimpleItem Name="Sensitivity" Value="0"/>
<tt:ElementItem Name="Layout"><tt:CellLayout Columns="22" Rows="15"><tt:Transformation><tt:Translate x="-1.000000" y="-1.000000"/>
<tt:Scale x="0.001042" y="0.001852"/>
<tt:RuleEngineConfiguration><tt:Rule Name="MyMotionDetectorRule" Type="tt:CellMotionDetector"><tt:Parameters><tt:SimpleItem Name="MinCount" Value="5"/>
<tt:SimpleItem Name="AlarmOnDelay" Value="100"/>
<tt:SimpleItem Name="AlarmOffDelay" Value="100"/>
<tt:SimpleItem Name="ActiveCells" Value="1wA="/>

This response gave me the resolution, framerate and encoding of the video feed. Finally I got this URI when I called GetStreamUri(Profile, StreamType):


I added username and password before the ip address and tested the feed with mplayer and ffplay — and finally with ZoneMinder. Success!

Nicest of all is: This procedure involved no network sniffer or guesswork. I just followed the ONVIF specifications. The procedure is deterministic and should be repeatable for any ONVIF camera.

This is a good basis for automating the manually performed steps. I am thinking of a “Probe ONVIF” button in the ZoneMinder “New Monitor” tab.


This post is part of The ONVIF series. See the other posts in the series here.


Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: