-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please Add ONVIF Support. - UniFi Protect 5.0 now Supports Third Party Camera's. #1355
Comments
The current known bug with unifi is you can't authenticate the onvif it fails even if you have correct credentials apparently they are aware but no fix date is posted yet |
I think still Wyze Docker would not work because it does not output or provide a working onvif protocol? Unless I'm not understanding that. |
I have an old local build with some basic support for ONVIF - auto discovery only works on a linux host as it seems to require the I don't have any ubiquiti gear to test it with, but I can try to clean up some of that code. |
Thank you, I guess I will have to learn to set it up on Linux hehe. I think for me getting away from the costly Blue Iris would be a really nice deal and I already had a UDM Pro already so this is pretty cool. Thanks for looking into it. |
BI's new licensing where if you go out of support they stop recording is pushing me to look elsewhere too although I suspect it'll be something closer to Frigate that Unifi although I run some of their hardware (not their NVR). The Wyze-bridge runs GREAT in a container on Linux! Wish something like this was available for the Ring lights I inherited - grr! |
I pushed a new This is still very basic and doesn't support any auth stuff yet, so you may have to set |
sorry still reading through the code ...did you have a separate port / url that will be used to stream a particular camera ect? |
You should be able to point it to your bridge on port 5000. |
Looking into seeing if its a firewall issue now. Does anyone else out been able to test this too? https://help.ui.com/hc/en-us/articles/26301104828439-Third-Party-Cameras-in-UniFi-Protect Preparing a Third-Party Camera
|
As far as I know mrlr8 said discovery is disabled so Unifi is not going pickup anything till that is added. So I assume, not sure if it's correct, but it should not work on the unifi stuff yet. |
Most of the ONVIF clients that I've been testing have an option to "manually" add a camera. I can enable the WS discovery, but it will require the Edit: latest |
Yeah currently the ubiquity one can only find it via discovery no manual adding yet. But this is their very first iteration so they might add more over time. |
Latest onvif image should have a services:
wyze-bridge:
container_name: wyze-bridge
restart: unless-stopped
image: mrlt8/wyze-bridge:onvif # onvif image
network_mode: host # host mode
environment:
- WS_DISCOVERY=true # enable discovery
.... |
@StoneLegion I've got a Ubiquity UNVR, and you can add cameras manually, though they didn't make it easy to find. See the screenshot below. However, I can't authenticate to the bridge. I tried username of
@mrlt8 I tried reviewing the authentication code for this but nothing stands out to me. Any ideas? |
Wow this is great work and thanks @Nayruden I will have to try this when I have time. Please keep us updated with it. |
Something is up with the authentication code, I believe. Even with authentication disabled
|
I agree. Something with auth if failing. I went to auth = false and turned off network host and then i could log in. I did want to say THANK YOU THANK YOU for your help working this. If it doesn't happen any time soon or at all ..its ok. It's just going to be pretty crazy fun if it does end up working. |
I made some changes to disable validating the authentication headers when Still not sure why authentication is failing when |
which tag? i see three? or should we just pull the code and build the image locally? |
All the onvif related stuff should be in the onvif tag or you can build the image from the onvif branch locally. The latest onvif image should show the |
With
It still fails with "authentication failed" with |
It works with {
"device": {
"manufacturer": "Wyze Bridge",
"model": "onvif Build [X86_64]",
"firmwareVersion": "v2.10.3",
"serialNumber": 0,
"hardwareId": "X86_64 ONVIF BUILD [2024-10-02t15:44:22.474z] 44c1fc6"
},
"snapshotUri": "http://192.168.1.74:5000/snapshot/test2.jpg",
"streams": [
{
"resolution": {
"width": 1920,
"height": 1080
},
"encoding": "H264",
"bitrate": 5120,
"uri": "rtsp://192.168.1.74:8554/test2"
},
{
"resolution": {
"width": 1920,
"height": 1080
},
"encoding": "H264",
"bitrate": 5120,
"uri": "rtsp://192.168.1.74:8554/test"
}
],
"camera": {},
"profiles": [
{
"$": {
"token": "test2",
"fixed": true
},
"name": "test2",
"videoSourceConfiguration": {
"$": {
"token": "VideoSourceConfig_1"
},
"sourceToken": "VideoSource_1",
"bounds": {
"$": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080
}
}
},
"videoEncoderConfiguration": {
"$": {
"token": "VideoEncoderConfig_1"
},
"encoding": "H264",
"resolution": {
"width": 1920,
"height": 1080
},
"rateControl": {
"bitrateLimit": 5120
}
}
},
{
"$": {
"token": "test",
"fixed": true
},
"name": "test",
"videoSourceConfiguration": {
"$": {
"token": "VideoSourceConfig_1"
},
"sourceToken": "VideoSource_1",
"bounds": {
"$": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080
}
}
},
"videoEncoderConfiguration": {
"$": {
"token": "VideoEncoderConfig_1"
},
"encoding": "H264",
"resolution": {
"width": 1920,
"height": 1080
},
"rateControl": {
"bitrateLimit": 5120
}
}
}
]
} From UNVR's perspective, it's one camera with multiple streams. It picked the first stream for me. @mrlt8 we need a way to pick which specific stream we want ONVIF to pick up. Maybe add an endpoint like To get this far, my change was simply to add def get_profiles(streams):
resp = """<trt:GetProfilesResponse>
"""
for stream in streams:
resp += f"""<trt:Profiles token="{stream}" fixed="true">
<tt:Name>{stream}</tt:Name>
<tt:VideoSourceConfiguration token="VideoSourceConfig_1">
<tt:SourceToken>VideoSource_1</tt:SourceToken>
<tt:Bounds x="0" y="0" width="1920" height="1080"/>
</tt:VideoSourceConfiguration>
<tt:VideoEncoderConfiguration token="VideoEncoderConfig_1">
<tt:Encoding>H264</tt:Encoding>
<tt:Resolution>
<tt:Width>1920</tt:Width>
<tt:Height>1080</tt:Height>
</tt:Resolution>
<tt:RateControl>
<tt:BitrateLimit>5000</tt:BitrateLimit>
</tt:RateControl>
</tt:VideoEncoderConfiguration>
</trt:Profiles>
"""
return resp + "</trt:GetProfilesResponse>" |
Actually, I discovered that it is recording from both my devices even though it shows up as one camera. One of them is under the "high quality" recording, the other is under the "low quality" recording. 🤣 |
I got the snapshot URI working by passing it the creds for |
If you can share you setup with screenshots later I love to see them. Sadly been away so I have not had the pleasure of messing around with it, but I love to see it in action. Once the kinks are worked on posting this on wyze / ubnt subreddits/facebook will really help bring more people to this project. Buying a single time investment into the UNVR or Dream Machine vs none stop license fee of Blue Iris is going make this amazing. Thanks for everyone hard work on testing and of course mrlt8 for making this into reality. |
It works just like my Ubiquiti camera now as far as I can tell. It's only missing the ability to scrub (playback only updates when you pick a time instead of updating on the fly as you scroll back) and events. |
Co-Authored-By: Brett Smith <16591+nayruden@users.noreply.github.com>
Thank you @Nayruden, I added
Unfortunately, I don't think most onvif clients will allow you to specify the path like that, however, I believe you can keep adding the "same" device multiple times and just select the appropriate profile for each camera. |
Crazy idea....what about a port range to open up. Like port 6000s. Then each onvif stream gets it's own port that would proxy to the correct camera |
@mrlt8 and @Nayruden -Great work on getting this working!!! I have it showing up in Protect now. I have 4 Wyze cams, so getting them to show as individual cams in Protect would still be preferred. With the current setup, any idea if we can modify which one is showing in Protect? Right now, it is picking up my "side" camera, but I really want my "Driveway" camera to be the one recording. |
@mrlt8 Unfortunately, you are right -- it does not accept a path. It only accepts an IP or hostname with a port. The way I got around this was that I added a bunch of alias domains on my network (EG So, as far as the initial registration, our only options are to vary the hostname / IP or the port as idaband suggested. I suspect most people would find the hostname registration straightforward enough (can do it from their router or PiHole, etc). In order to ease registration with that, maybe we could have a drop down selector on the Wyze bridge admin UI for which camera it will present to ONVIF? The camera adoption flow would then be as follows....
The hostnames are different so the NVR treats them as separate devices. Here's an example of how UNVR sees the devices at the end of this. (I modified the SOAP return so the snapshots would work in these examples) Cam 1 {
"device": {
"manufacturer": "Wyze Bridge",
"model": "onvif Build [X86_64]",
"firmwareVersion": "v2.10.3",
"serialNumber": 0,
"hardwareId": "X86_64 ONVIF BUILD [2024-10-02t15:44:22.474z] 44c1fc6"
},
"snapshotUri": "http://wbadmin:pass@cam1.wyze.my.house:5000/snapshot/cam1.jpg",
"streams": [
{
"resolution": {
"width": 1920,
"height": 1080
},
"encoding": "H264",
"bitrate": 5000,
"uri": "rtsp://wb:pass@cam1.wyze.my.house:8554/cam1"
}
],
"camera": {},
"profiles": [
{
"$": {
"token": "cam1",
"fixed": true
},
"name": "cam1",
"videoSourceConfiguration": {
"$": {
"token": "VideoSourceConfig_1"
},
"sourceToken": "VideoSource_1",
"bounds": {
"$": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080
}
}
},
"videoEncoderConfiguration": {
"$": {
"token": "VideoEncoderConfig_1"
},
"encoding": "H264",
"resolution": {
"width": 1920,
"height": 1080
},
"rateControl": {
"bitrateLimit": 5000
}
}
}
]
} Cam2 {
"device": {
"manufacturer": "Wyze Bridge",
"model": "onvif Build [X86_64]",
"firmwareVersion": "v2.10.3",
"serialNumber": 0,
"hardwareId": "X86_64 ONVIF BUILD [2024-10-02t15:44:22.474z] 44c1fc6"
},
"snapshotUri": "http://wbadmin:pass@cam2.wyze.my.house:5000/snapshot/cam2.jpg",
"streams": [
{
"resolution": {
"width": 1920,
"height": 1080
},
"encoding": "H264",
"bitrate": 5000,
"uri": "rtsp://wb:pass@cam2.wyze.my.house:8554/cam2"
}
],
"camera": {},
"profiles": [
{
"$": {
"token": "cam2",
"fixed": true
},
"name": "cam2",
"videoSourceConfiguration": {
"$": {
"token": "VideoSourceConfig_1"
},
"sourceToken": "VideoSource_1",
"bounds": {
"$": {
"x": 0,
"y": 0,
"width": 1920,
"height": 1080
}
}
},
"videoEncoderConfiguration": {
"$": {
"token": "VideoEncoderConfig_1"
},
"encoding": "H264",
"resolution": {
"width": 1920,
"height": 1080
},
"rateControl": {
"bitrateLimit": 5000
}
}
}
]
} Since the NVR remembers the full path to the correct device after the initial registration, it doesn't matter if Wyze bridge is advertising another camera on ONVIF later. |
@Nayruden |
Another option could be to use WS-Discovery to advertise a path for each of the cameras? I believe most clients will accept whatever path the auto discovery returns e.g. |
@idaband I hard coded the creds because I'm lazy. I'm sure @mrlt8 can come up with a better solution for this. Use the code below to replace def get_snapshot_uri(profile):
hostname = env_bool("DOMAIN", urlparse(request.root_url).hostname or "localhost")
if WbAuth.enabled:
hostname = f"wbadmin:pass@{hostname}"
return f"""<trt:GetSnapshotUriResponse>
<trt:MediaUri>
<tt:Uri>http://{hostname}:5000/snapshot/{profile}.jpg</tt:Uri>
<tt:InvalidAfterConnect>false</tt:InvalidAfterConnect>
<tt:InvalidAfterReboot>false</tt:InvalidAfterReboot>
<tt:Timeout>PT0S</tt:Timeout>
</trt:MediaUri>
</trt:GetSnapshotUriResponse>""" |
@mrlt8 to be honest I didn't look at the discovery option. If it requires host networking and the same subnet it wouldn't have worked in my case anyway. |
Nevermind... I'm a big dummy. I just saw that Wyze bridge does support lower quality substreams with |
Nope -- doesn't matter what the bitrate is set to. It seems like UNVR will always take the first stream as "high quality" and the second as "low quality". |
Awesome! I've got scrubbing working now. I have def get_profiles(streams):
resp = """<trt:GetProfilesResponse>
"""
resp_high = ""
resp_low = ""
for stream in streams:
bitrate = 200 if "-sub" not in stream else 100
resp_add = f"""<trt:Profiles token="{stream}" fixed="true">
<tt:Name>{stream}</tt:Name>
<tt:VideoSourceConfiguration token="VideoSourceConfig_1">
<tt:SourceToken>VideoSource_1</tt:SourceToken>
<tt:Bounds x="0" y="0" width="1920" height="1080"/>
</tt:VideoSourceConfiguration>
<tt:VideoEncoderConfiguration token="VideoEncoderConfig_1">
<tt:Encoding>H264</tt:Encoding>
<tt:Resolution>
<tt:Width>1920</tt:Width>
<tt:Height>1080</tt:Height>
</tt:Resolution>
<tt:RateControl>
<tt:BitrateLimit>{bitrate}</tt:BitrateLimit>
</tt:RateControl>
</tt:VideoEncoderConfiguration>
</trt:Profiles>
"""
if "-sub" in stream:
resp_low += resp_add
else:
resp_high += resp_add
return resp + resp_high + resp_low + "</trt:GetProfilesResponse>" |
It's been a week since the last reply. Is it running solid and well for yo guys? Worth migrating from Blue Iris to it or is there some stuff that needs to be fixed either UBNT side of things on the Hack? |
I would like to test this, How would i Enable ONVIF in a Portainer config? Or is that not supported? |
It's been working rock-solid for me! I've got four Wyze cameras streaming to UNVR now and they work just like the official Unifi cameras, except there's no motion detection. |
@Nayruden - sorry if this is a dumb question, but where did you put the "Filter_Names" option? Is that in the Docker settings or in the onvif.py file? I am running this on UnRAID, using the pre-built package. Also, I can't find the onvif.py file anywhere to modify. I need to keep looking for that. I have been recording one camera for the last week, but it is bringing in two different streams for that one camera. |
|
@Nayruden I follow the idea of having multiple hostnames pointing to the same IP, but I'm missing how we get wyze-bridge to present the single filtered camera on each host name. Are you running multiple copies of wyze bridge, each filtered to a single camera? |
No, I'm only running one copy. ONVIF is a one-time setup process. ONVIF hands back the RTSP stream URI and the NVR only ever cares about that URI that was handed back going forward. The wyze-bridge hands back RTSP streams that include the name of the camera and it doesn't matter what ONVIF passes to other clients in the future since it only ever grabs the data once. EG, see #1355 (comment) for how it stores the camera data after getting it from ONVIF -- it has the RTSP stream saved and that's all it ever cares about going forward. At least, that's how UNVR works. I'm assuming others would be the same. |
i have 8 cameras...i'm getting ready to use a new PI for all the work. @Nayruden does the onvif image have hardware acceleration in it? |
Unless you're doing something unusual, my understanding is that wyze-bridge does a stream copy (no additional processing with CPU or GPU required). |
wish know how work this , understanding its for cameras with onvif type? i have a few brands, use other method to able to play on synology surveillance, but its possible do on bridge great. understanding need inject onvif.py and how its on the chapgpt chat file with the info about my cameras? thats a python file ? it gives a link address but after you shutdown camera or open app it gives a new address. no fully sure about this exactly but do some like that , no checked again just now it gives something like this , rtsp://192.168.2.208:554/live/1jxxxxxjzaxa_p0_UFDWJJDBIHUE , then change last letters ramdomly |
ok i figure out this lol . i did in the past cant remember before. one above give a different token? on the link , then go2rtc its able to get a permanent link onvif://email:password@192.168.2.208:80?subtype=SubProfileToken go2rtc discover camera with some data, and generate this one above, and you use to get m3u8 links there so how i can use any of this for use onvif? i have already running onvif docker with this services: wyze-bridge: but not discovers any camera onvif. |
Describe the bug
I'm wondering if anyone able to get it to work? It says any camera that uses ONVIF Support, not sure if we emulate or can emulate such a feature?
I have a Dream Machine Pro, and tbh I love to get away from Blue Iris.
Affected Bridge Version
0.0
Bridge type
Docker Run/Compose
Affected Camera(s)
No response
Affected Camera Firmware
No response
docker-compose or config (if applicable)
No response
The text was updated successfully, but these errors were encountered: