BreeeZe / rpos

Raspberry Pi Onvif Server
http://breeeze.github.io/rpos
MIT License
647 stars 147 forks source link

ptz rest api #68

Closed utya1988 closed 4 years ago

utya1988 commented 5 years ago

Hello. I have cam xiaami dafang with hack (https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks). This cam doesn't work with onvif. But have rtsp stream and ptz control by restapi command (https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/blob/master/integration/tinycam/custom_vendors.xml). Can i use your project with rtsp stream from this cam and have ptz control using some proxy ptz->restAPI? Can i configure rpos for using ptz/restapi mode? Thanks

RogerHardiman commented 5 years ago

Yes that would work - although there may be one problem.

So in RPOS you would use rposConfig.json to point at the RTSP server inside the camera. RPOS would then handle the ONVIF Discovery and the ONVIF PTZ. In the RPOS source is a PTZ driver which converts ONVIF PTZ into several different formats (a Raspberry Pi Pan/Tilt Motor system, into Pelco protocol, into Sony VISCA protocol). You would need to edit this file to generate PTZ commands for your camera.

So that should work.

The only problem could be if the CCTV viewing software is unhappy sending ONVIF commands to one IP address and getting RTSP streams from another. Some CCTV software changes the IP address as part of the software to work around NAT Eg a camera is 192.168.0.2 You access it via the internet and do ONVIF commands to Public IP address 66.55.44.33 When the CCTV software gets the RTSP address it may say "rtsp://192.168.0.2" (ie the local address) and CCTV software changes it to rtsp://66.55.44.33 So your software may modify the RTSP address and not work

The fix for that is to look at the Live555 project. They have a RTSP proxy. You can run that on the Raspberry Pi. Then the ONVIF and the RTSP stream are both generated from the Pi.

If you get something working please let me know. Would be great to include any improvements into RPOS

utya1988 commented 5 years ago

thanks for reply.

The only problem could be if the CCTV viewing software is unhappy sending ONVIF commands to one IP address and getting RTSP streams from another. Some CCTV software changes the IP address as part of the software to work around NAT Eg a camera is 192.168.0.2 You access it via the internet and do ONVIF commands to Public IP address 66.55.44.33 When the CCTV software gets the RTSP address it may say "rtsp://192.168.0.2" (ie the local address) and CCTV software changes it to rtsp://66.55.44.33 So your software may modify the RTSP address and not work

i will use this system in local network, so i think it's not problem for me. but thanks for advice.

So in RPOS you would use rposConfig.json to point at the RTSP server inside the camera. RPOS would then handle the ONVIF Discovery and the ONVIF PTZ. In the RPOS source is a PTZ driver which converts ONVIF PTZ into several different formats (a Raspberry Pi Pan/Tilt Motor system, into Pelco protocol, into Sony VISCA protocol). You would need to edit this file to generate PTZ commands for your camera.

Could you explain me, i must edit this config format?

https://github.com/BreeeZe/rpos/blob/master/services/ptz_service.ts https://github.com/BreeeZe/rpos/blob/master/services/stubs/ptz_service.js https://github.com/BreeeZe/rpos/blob/master/lib/PTZDriver.ts

I want deploy project on raspberry and get stream from ip cam.

RogerHardiman commented 4 years ago

You need to edit the file PTZDriver.ts to use your REST API (there is no need to change ptz_service.ts or ptz_service.js)