I'm trying to listen to MotionDetectedMessage and fetch the associated images or video with the motion detection event. I've subscribed successfully but it seems that a motion event never triggers. What could be the issue?

I have two cameras on a test server which just play a pre-recorded video on loop. The video does have lots of motion (cars going back and forth on a street).

Motion Detection is active for both.

Is there something else I need to look at like rules, alarm definitions etc?

Also, will SnapshotList be populated for such events or is there some other way I’ll need to use to get the images/video?

Setting up motion detection is not really a development question and it is important that you know that motion detection is correctly configured and working when you try to use it from MIP SDK code. You can verify that the event happens by using Alarm List in the Smart Client and configure it to show events instead of alarms.

Alternatively, you can use the AlarmEventViewer sample and see when the events occur.

https://doc.developer.milestonesys.com/html/index.html?base=samples/alarmviewer_sample.html&tree=tree_search.html?search=alarmeventviewer

You can see Motion Detection event on the list when the event happens.

This sample will also show you the recommended way of subscribing and getting the Motion Detected events.

The event will not in itself include an image, so what you do is that you use the information about the camera and the time of the event to retrieve the image. I think this old question covers well what you want to achieve: https://developer.milestonesys.com/s/question/0D53X00006OatdCSAR/camera-snapshot-when-motion-detection

Thanks very much for the reply @Rie Kiuchi (Milestone Systems)​ .

The problem as it seems to me now is that video extraction is not even supported in Event Server plugins and as Bo pointed out in his answer it doesn’t seem right to do it in the Smart or Management client either.

Can I call the recording server over HTTP from within the Event Server plugin and get the video from there? (async task)

I need to send the video/images to an external server along with the camera and site info. I suppose I can send all the needed info, credentials etc to the external server which can then pull the video from the recording server directly (showcased in the VideoViewer Component sample I think)…but I want to avoid that round trip for the sake of speed. What would you suggest?

@Bo Ellegård Andersen (Milestone Systems)​ @Peter Posselt Vergmann (Milestone Systems)​

Also, if one does go with the “external server pulls video from recording server” approach, how can I get the complete credentials needed to connect to the recording server from within the plugin? (The plugin can then send these credentials to the external server along with event timestamps etc, whereat the external server will pull the video)

Hi Usama. We have not implemented streaming support in the Event Server as this would consume extra resources (for decoding the video) and we don’t want to put this kind of load on the Event Server. So even though you might be able to access the Recording Server interfaces from the Event Server by writing your own code we strongly recommend not doing so.

Instead I would suggest moving your code to a separate service (could then be installed on same machine as Event Server or any other machine). In here you can listen to the same messages (including motion detection) and you can then use the different video source classes (which are available in the standalone environment) for retrieving the video. Credentials for logging in to the VMS would of course have to be provided to the service (e.g. during installation) and stored safely.

@Peter Posselt Vergmann (Milestone Systems)​ thanks very much for your explanation. It probably prevented me from making a bad architectural decision.

In regards to my follow up question, after having received an event on the Event Server is there a way I can send some auth credentials (host, port, username, password etc…maybe an auth token?) to the external service which it can then use to pull the video from the relevant recording server?

I’d also really appreciate it if you could please specify the HTTP endpoint(s) that the external service can use to hit the recording server and pull the video, where they are documented etc.

Again, thank you so much!

@Bo Ellegård Andersen (Milestone Systems)​ @Rie Kiuchi (Milestone Systems)​

Hi again. Credentials cannot be passed on from the service. They will have to be provided to and stored by the service.

The easiest regarding connecting is to use the .NET classes in the SDK, but if you need to do it in a non-.NET language you can have a look at our protocol integration documentation: https://doc.developer.milestonesys.com/html/index.html?base=content_3.html&tree=tree_3.html

There you will find info about the API endpoints. Also, try have a look at the TCP Video Viewer sample as it will show you both how to log in and how to retrieve video: https://doc.developer.milestonesys.com/html/index.html?base=samples/tcpviewer_sample.html&tree=tree_3.html

It is written in C#, but without using any of our libraries so should be fairly simple to transfer to another language.

Please explore the “sample” that I made, I believe it is a fit for you (if using .NET and the MIP library like you would if developing a plugin).

https://developer.milestonesys.com/s/question/0D53X00006OatdCSAR/camera-snapshot-when-motion-detection