How To – Do Stream Motion Detection

We have been asked to look at several features relating to the transcoder, one being motion detection. We did a little digging and it appears Wowza Streaming Engine provides access to frames after they have been decoded. There are several posts such as

Stack OverFlow

and a somewhat more complete example

Wowza Code Example

This module demonstrates how to perform motion detection on an incoming stream. It does require the use of the Wowza Streaming Engine transcoder as it does require access to the decoded frames. It is only a proof of concept module so there is no doubt room for improvement.

You will need to configure the module in the Application.xml, as the last module in the Modules section as follows

Module setup:

<Module>
<Name>MotionDetection</Name>
<Description>MotionDetection</Description>
<Class>guru.thewowza.example.transcoder.MotionDetect</Class>
</Module>

You do also need to configure the Application.xml to use the transcoder as follows

Set the the LiveStreamTranscoder so have ‘transcoder’ set, this can also be done in the Wowza Streaming Engine Manager

<LiveStreamTranscoder>transcoder</LiveStreamTranscoder>

You shoud also use the motion.xml template provided in the download by setting the template as follows

<Templates>motion.xml</Templates>

The template is extremely simple and only has 1 encode enabled. This is required as without any encode blocks enabled then no decoding occurs and subsequently no motion detection can be performed.

An example ‘Application.xml’ is provide in the package

There are two additional properties than can be set in order to control the motion detection being performed.

motionDetectStreamName – The name of the stream to perform motion detection on. It must be a source stream and must NOT be the output of the transcoder. It has a default of myStream.

Ex:

<Property>
<Name>motionDetectStreamName</Name>
<Value>myStream</Value>
<Type>String</Type>
</Property>

motionDetectPixelCount – This controls how many pixles need to change before detection is triggered. This is effectively a sensitivity setting. It has a default of 2500, and a maximum based on the resolution of the input stream. As the decoding part of the transcoder is being used. The higher the number the less sensitive the detection is as it is the number of pixels detected as changed.

Ex:

<Property>
<Name>motionDetectPixelCount</Name>
<Value>2500</Value>
<Type>Integer</Type>
</Property>

You can download an example Application.xml, motion.xml along with a jar file and source code from Here.


Comments are closed.