I have 16 analog cameras feeding in to my Defender DVR. I'm able to access the camera feeds locally by going to a specific port and entering login details using an ActiveX control in IE. I can also view them through apps from the Apple apps tore on my iPad by simply entering my external IP address, port number, and login credentials.
My question is, if I wanted to create an app similar to those in the app store. How would I go about communicating with the DVR's stream of videos/images?
I'd image I need to poll the IP address to get the data but I'm not sure what type of connection is needed and what to expect there.
It seems that many DVRs defer to the same apps in the marketplace so my guess is that they all conform to some standard when outputting the data.
Thank you.
A lot of cameras stream data via HTTP using the Mixed-Replace Content-Type. If you can access your camera on a browser, it is very likely that it uses HTTP.
Assuming this is your case, you'll have to find out what URL your camera uses to serve the stream. So you could:
- Try to find a list like this on the internet, by Googling your camera model
- Inspecting the browser yourself (this will require some knowledge on HTML5)
Once you have the URL,you can be sure if you're dealing with a Mixed-Replace request, if you have a terminal with curl, you can use something like:
$ curl --head http://user:password@192.168.99.230/video.cgi
My camera returns the following header:
HTTP/1.0 200 OK
Server: alphapd
Date: Thu Jan 9 09:04:59 2014
Pragma: no-cache
Cache-Control: no-cache
Content-Type: multipart/x-mixed-replace;boundary=video boundary--
This means I have a Mixed-Replace response separated by the "--video boundary--" string (look to the Content-Type field).
The request body looks like this:
--video boundary--
<metadata>
<image>
--video boundary--
<metadata>
<image>
...
(Neverending request body of real time delivered images)
Now your approach will depend on which application you want to embed the stream. On my case, I just needed to put them on a web page, so Firefox did me a favor and I could integrate it with:
<img src="http://user:password@192.168.99.230/video.cgi">
But you might have to be parsing and capturing each incoming image by yourself depending on your application.
There are standards out there so you just need to look around also don't expect any dvr manufacturer to give you api access many have tried they just dont give it away any way you don't want to be tied down to a specific dvr implementation I would advice you start with the ispy c# code http://www.ispyconnect.com and that will give you an idea of how it works in general since Ispy supports many types of cameras be it ip or webcam...
Code for analog cameras will be more difficult to find so good luck...
来源:https://stackoverflow.com/questions/29018392/how-do-i-grab-cctv-dvrs-broadcast-for-custom-application