Pelco Developer Network (PDN)

Control Pelco camera with PHP Script

Opinion needed ASAP

Hi Guys
How are you doing
Please i wanna integrate two system together both written in C# tho, An Intrusion Detection System and Pelco Cameras

The Intrusion System has XML file where it relate all its information to the network every 30sec now i wanna write a PHP script that will get this info and send it to pelco to display on the screen when there is a particular signal from this file,
But please i want to be very sure if my PHP script can control Pelco camera?

Hello!

I believe that you may be able to do what you indicate... but to be certain I need more information. When you say "can control Pelco camera" -- what kind of control are you intending to do? Are we specifically talking about physical control and movement like PTZ? Are we talking about pulling a stream using the script?

We would start by recommending ONVIF as a means to write a camera driver to control behavior on an ONVIF-compatible camera (as most Pelco cameras are). Alternatively you could use Pelco API, though admittedly making requests to the camera's API services (like PositioningControl or StreamControl) is not very different than using ONVIF.

Hi

PelcoChris, Thank you so much for showing concern. This is the scenario of what i'm trying to achieve. I have two separate system i wanted to integrate together, One is what we called the Instrusion Detection System (IDS) and two is different Pelco Camera products.

The IDS is an Alarm triggering Unit that sense intrusion. The way it works is that Fibre sensor are laid in the Perimeter where it will protect and it is detached into Zones, and all zones are terminate at a box called DB 32, From there fibre cable convene the signal to the server room and it will be received by a device called Alarm Processing Unit (FD 525R), the device decode the signal and transform it into DATA then sent into the network through the Ethernet Port. Upon getting into the network another Unit of system called Fibre Commander (It's a Workstation installed with the Fibre commander software) Picks the information using the XML file communication and translate this information (Alarm signal) to the Monitor screen for Operator to be aware of the danger from the particular zone.

IN each of this zone on the field we have Pelco camera product installed like PTZ, Panoramic, etc. So what we want to achieve is that, whenever there is an alarm signal from any zones Pelco camera in that zone should automatically open a live stream of that zone on the monitor screen for operator to get a clear view of the location without having to contact any body to check.

Note:
Both systems IDS and Pelco has SDK for thrid party integration
We want to just open live stream of any camera irrespective of their make on the monitor
Both Product SDK are written in C# but we are thinking of using a language we are comfortable with which is PHP

How do we intend to achieve this;
We will write a control application which will be on workstation (PC) and on the same network with these systems, so if an alarm signals and pass information to the network we grab it and that will be from the XML file which obviously can be gotten using PHP syntax, now passing the information as command to the Pelco camera product using PHP is the concern, if it can be done or not? that's why i asked if pelco camera are compatible with PHP or not and if so how do i go about it?

I will reply appreciate your input on this Chirs, and also your observation
and probably better ways to get it done without going through much of this. I will be waiting for your reply ASAP

Thank you
Best regards

Thanks for your post and additional information. I'll break down a few points and my suggestions on a potential approach.

It sounds like the events will be coming from the IDS system to a centralized server / location that will then request the live camera stream. This means that the amount of behavior that you'll need to get the camera to do is limited to live video (and maybe PTZ). If I'm correct on these aspects, then we can proceed to some suggestions.

My first suggestion is to investigate and utilize ONVIF. Most Pelco cameras that were released in the last several years are ONVIF compliant. In addition, learning and understanding this does allow for a larger library of potential cameras - while of course I'd want Pelco cameras to be used in all cases :). Writing a driver to use ONVIF libraries would be the best route to take.

As a second suggestion, you could use Pelco API WSDLs to communicate with the camera's Web Services to initiate a stream that way. This would not be very dissimilar to using ONVIF, so if you're going to use an API and send requests to a camera in this manner ... ONVIF would probably be better.

These are my first suggestions because of your desire to use PHP. While we do have an SDK that can help streaming from Pelco cameras ... it is compatible in C# and C++ (not PHP). It is also older and no longer under active development, so today we recommend using ONVIF for camera drivers as the primary way to do it.

The Pelco SDK is at its core simply a wrapper for making Pelco API calls to Pelco devices. That's really all it is. It does, admittedly, have a way to render the video that was written using Pelco-based libraries that are no longer under development or updating. That's why we recommend ONVIF, because then our developers aren't stuck using proprietary 3rd party developed libraries. They can instead develop their own driver using available language agnostic means.

Thank you PelcoChris you are really a genius and so kind for this great work

You got the first point right on what we want to achieve. But on your suggestion for ONVIF, do they have the function for displaying live stream and probably controlling of PTZ position or its just a communication gateway to the camera, which mean we are going to be developing our own function of what we want.

Then is it web based stream or we can use other means to display live stream. I would really appreciate if you can help on how to use the ONVIF, probably a few stuffs on it. Thank you. Best regards.

No problem, and thanks for your kind words.

You can use ONVIF to start streams and control PTZ. ONVIF is a open standard that is implemented on devices to attempt to have a unified API. We have a page on PDN to compare some of the features between Pelco API and ONVIF, and what is supported here: Comparison of Pelco API and ONVIF API. In addition, there is another page here that lists Pelco Products Supporting ONVIF. These pages were under the "Pelco API" link on the list on the left side of our web page.

For obtaining streams, I might also recommend streaming using RTSP. That may even be the simplest of all to obtain an RTSP live stream from the camera directly. We have some articles on Pelco.com describing this here: Article #8901 Sarix RTSP URL, and another article here Article #12001 What is the Sarix RTSP URL?. Those methods might be very simple to pull a live video stream. Using a tool such as VLC you can obtain a Network stream from Pelco RTSP URLs with that application, possibly even using some of those tools to stream.

Finally for ONVIF-related questions, your best avenue for support that I could suggest would be to start with the ONVIF website here: www.onvif.org, or searches online. As an open standard, there are answers for that and experts out there (I'm not much of one). There is also an application available on SourceForge that I've used called ONVIF Device Manager (aka ODM) here: ONVIF Device Manager.

Hopefully you'll have success with these options and suggestions.

Many thanks

Lemme work on your suggestions and do some sort of R&D to see what i can get, then i will get back to you to tap from your excellent wealth of knowledge on the project.

thank you chris.

Sure thing, sounds like a plan!

Hi PelcoChris

Thank you for the insightful idea the other time,
I have been through the ONVIF Documentation and i can say it all solves our problem but quite big

I spoke with a colleague of mine concerning this integration and he provided another idea, which i'm seeing to be simple, and can be easily implemented, Since pelco is an IP camera we are thinking we can program it in a such a way that any cameras, while it receives an action messages from the Alarm Unit can be triggered to display its live video streaming through the web browser using PHP tho,
What do you think about it? Any idea on it workability ?

Certainly.

It's been years since I did anything using PHP myself personally, and that was prior to working with video. As it sounds like your team is more familiar with PHP the specifics of how to design a solution using that is really up to you. What I wanted to do is to provide options on some ways that video or images can be obtained from the camera.

My understanding was that you should be able to utilize WSDL files (ONVIF or API) for TCP requests as necessary, since those are language agnostic. For the actual video I would suggest using RTSP streams from a camera's RTSP URL. Displaying that stream is specifically really up to you. You might be able to use VLC libraries for that, perhaps.

An alternative might be to perform HTTP GET requests to the camera's JPEG URL and display them as rapidly as you can, and therefore simulate an MJPEG stream that way. It'd be simplistic but probably functional too, though the frame rate is likely to be poorer than using RTSP.

great one there Chris, I love it.

I will update you as the project continues
Thank you very much for your time
Best regards

Sounds good, you're welcome!

Hello Chris

How are you doing.
Please i want to ask if there is a way i can remove the login details of pelco camera when accessed from the web browser.

Then for the initial question on the integration, i found a way of doing that, what i just did was to use php header redirect on command from the Alarm device here's what i used :

Untitled Document

and i also used this :

<?php
ob_start(); // ensures anything dumped out will be caught

// do stuff here
$url = 'http://192.168.5.191'; // this can be set based on whatever

// clear out the output buffer
while (ob_get_status())
{
ob_end_clean();
}

// no redirect
header( "Location: $url" );

?>

Hello there!

I've looked a bit this morning, but sadly I was unable to find any way to disable the camera's request for credentials on the web browser. The only time I can recall not needing a login was on a factory defaulted camera, and only for some models. You could reach out to Product Support to ask that team if they are aware of any other way to disable the credentials for the camera's web GUI.

For the rest of your post, my apologies -- I'm a little confused what the question is for this bit. I haven't done much php in all honesty. I believe that you can send the credentials with headers in the request, but the specifics of it I'm uncertain about.

Hello

Hi chris how are you .

Thank you for all the support you have been provided. This is a method have not tested but i guess bypassing login can be done by http://login:pass@xxx.xxx.xxx.xxx:xxx

The main aim of contacting you is that have not been able to stream live feed of the camera in my script and i'm finding it hard to use the Onvif. Please can you render any help ?

Hmm, my suggestion would be to start with ONVIF Device Manager (a free application you can get online), and use Wireshark to monitor the network traffic of requests and responses as a basis for making the requests and their structure.

If you wanted to start even more basic, you could start with this page about Fetching a JPEG image to work from a still image and then work on streaming from there. We do have an old sample as well using JPEG streaming here: Pelco API and SDK Code Samples. I will advise you that these pages and samples are several years old now and have not been updated in a very, very long time. They may work well for a basis to help get started.

I do wish that I could provide you with more. Advice and suggestions are mainly the best that I can offer to help you out in your efforts.

Thank you chris

I resolved the issue, i just used javascript to call up the IP of the camera in my web browser. Tho i have not tested on a network but i'm certain it will work . Still figuring out on how i can integrate vlc player in my web browser that comes up when the alarm triggers so as to display the rstp for better view