-
Notifications
You must be signed in to change notification settings - Fork 819
New Tuya camera support #1730
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
New Tuya camera support #1730
Conversation
|
I got this error when trying it: The config: streams:
rua_tuya:
- tuya://openapi.tuyaus.com?device_id=x&uid=x&client_id=x&secret=xMaybe it's something related to my camera specifically, but it shouldn't panic anyway. PS: I got it working for another camera. |
yeah it shouldn't panic, will take a look |
|
Can you please also add an example on how to change the resolution to your PR description? |
done |
|
For the camera where go2rtc crashes with a panic, there seems to be no "skill" entry in the response from your camera https://github.com/seydx/go2rtc/blob/ff00484328d2e2cf3f75dea4616529f52dbf356d/pkg/tuya/api.go#L305 It looks like I need to rewrite this somewhat so that it falls back to default video/audio. |
|
Thank you! I guess my camera doesn't support changing the resolution through the WebRTC API because regardless of Some other feedback:
|
Do you want me to run some Tuya API against my camera? I can do it relatively easy through the Tuya IOT Debug function. |
Yeah that would be nice, this is the endpoint: https://github.com/seydx/go2rtc/blob/ff00484328d2e2cf3f75dea4616529f52dbf356d/pkg/tuya/api.go#L258 should look like: {
"result":{
"audio_attributes":{
"call_mode":[
1,
2
],
"hardware_capability":[
1,
2
]
},
"auth":"h85L4pljbuHFR0a/iTgViwA35xi3yTl3NyMsFQL5****",
"id":"6cf2b6d2b09a2f8597****",
"moto_id":"moto_cnpre002",
"p2p_config":{
"ices":[
{
"urls":"stun:49.234.141.77:3478"
},
{
"urls":"stun:tx1stun.tuyacn.com:3478"
},
{
"urls":"nat:tx1nat.tuyacn.com:3478"
},
{
"urls":"nat:tx2nat.tuyacn.com:3478"
},
{
"credential":"kb/EA2whGCcNSM5FjXV2dxAM1MU=",
"ttl":36000,
"urls":"turn:49.234.141.77:3478",
"username":"1600883205:6cf2b6d2b09a2f8597****"
},
{
"credential":"kb/EA2whGCcNSM5FjXV2dxAM****",
"ttl":36000,
"urls":"turn:tx1turn.tuyacn.com:3478",
"username":"1600883205:6cf2b6d2b09a2f8597****"
}
]
},
"skill":"{"webrtc":3,"audios":[{"channels":1,"dataBit":16,"codecType":101,"sampleRate":8000}],"videos":[{"streamType":2,"profileId":"","width":1920,"codecType":2,"sampleRate":90000,"height":1080},{"streamType":4,"width":640,"codecType":2,"height":360}]}",
"supports_webrtc":true,
"video_clarity":4
},
"success":true,
"t":1600847205437
}
|
|
This is the output: {
"result": {
"audio_attributes": {
"call_mode": [
1
],
"hardware_capability": [
1,
2
]
},
"auth": "xx=",
"id": "xx",
"moto_id": "signaling14723",
"p2p_config": {
"auth": "xx=",
"ices": [
{
"urls": "stun:44.240.73.31:3478"
},
{
"urls": "stun:[2600:1f14:305f:5a01:3a96:c309:6fd1:4847]:3478"
},
{
"credential": "xx",
"ttl": 36000,
"urls": "turn:15.204.9.11:3478",
"username": "1747054638:eb05a8c8501ca6b9784gfw"
}
],
"moto_id": "signaling14723"
},
"protocol_version": "2.2",
"skill": "{\"webrtc\":3}",
"support_webrtc_record": false,
"supports_webrtc": true,
"vedio_clarity": 2,
"vedio_claritys": [
2,
4
],
"video_clarity": 2
},
"success": true,
"t": 1747018638601,
"tid": "d1178ccb2edc11f0b3586285baec33dd"
} |
|
Out of curiosity, this is the output for the camera which only works through HLS (at least in my tests): {
"result": {
"audio_attributes": {
"call_mode": [],
"hardware_capability": [
1
]
},
"auth": "xx",
"id": "xx",
"moto_id": "signaling14724",
"p2p_config": {
"auth": "xx",
"ices": [
{
"urls": "stun:54.148.238.22:3478"
},
{
"urls": "stun:[2600:1f14:305f:5a01:def3:5ab9:10ea:974e]:3478"
},
{
"credential": "xx",
"ttl": 36000,
"urls": "turn:15.204.8.186:3478",
"username": "1747054814:ebf031220b3de54904xgqs"
}
],
"moto_id": "signaling14724"
},
"protocol_version": "2.2",
"skill": "{\"webrtc\":2}",
"support_webrtc_record": false,
"supports_webrtc": true,
"vedio_clarity": 4,
"vedio_claritys": [
2,
4
],
"video_clarity": 4
},
"success": true,
"t": 1747018814643,
"tid": "3a0a92932edd11f0bc8ac69aa343f8ac"
}PS: It's a different camera, but it also panics in the same place. |
|
panic should be fixed, can you try pls, changed also the rtsp query to |
Not only the panic is gone, I can now stream that camera over WebRTC. Thanks!! |
Tested HLS? HLS does not work for my camera, have only black screen. Using ffmpeg as internal producer with disabled audio, because with audio the stream was not playable |
|
Wow, the stream for my camera which previously only worked through HLS is now possible with WebRTC too! |
|
Honestly I will probably never need to use HLS anymore, since WebRTC is working. HLS is such a mess. |
Yeah, that's probably it, I'm using it through pkgx. Probably they built it without HTTPS support. Tested both 5 and 7 though. |
streams:
bebe:
- tuya://openapi.tuyaus.com?device_id=xx&uid=xx&client_id=xx&secret=xx&hls=1 |
Yeah, looks like go2rtc doesn't play well with ADTS audio. |
|
If I were you, I'd remove I had the same issue when using my script. Was never able to get the BTW I tried your PR in my Frigate instance, with a proper ffmpeg, and I was able to get the black screen, just like I used to do using my script in HLS mode in go2rtc. So, again, I think your PR is doing what it's supposed to for HLS mode. The rest is up to go2rtc itself. |
Actually I cannot reproduce that. Maybe your camera outputs a different audio codec when in HLS mode than mine. For me the stream plays the same way with or without |
|
@seydx thinking more about the parameters, I think the following is what makes the most sense: Instead of |
done |
done |
|
Not sure if it's worth it, probably not, but you could get the user id using |
|
Another recommendation I would give is to name the
I guess keeping the same terminology across different interfaces helps increase predictability and reduce confusion. |
|
Hi, I tried using this PR, but I got the error:
Connect via email/password region EU: |
|
Well. This code don't work for my SmartLife account and for my Tuya account. I still don't know why. |
I tested this with Tuya. Using the Tuya cloud has been working for about two weeks. Direct login with login/password does not work when the EU region is selected. |
No issues for me with EU data center |
|
Maybe some of you can share your Tuya email and password with @seydx privately so he could try to reproduce the issue himself. Note Smart Life accounts are not supported. |
which country? |
Kazakhstan. Ping to this IP is ok: |
|
Ping works but the 443 port doesn't seem open/accessible: ~ ❯ ping 45.195.222.93
Pinging 45.195.222.93 with 32 bytes of data:
Reply from 45.195.222.93: bytes=32 time=358ms TTL=237
~ ❯ telnet 45.195.222.93 443
Connecting To 45.195.222.93...Could not open connection to the host, on port 443: Connect failedFrom Brazil. |
Same. @seydx there is problem from Tuya? Why I got wrong MQTT server from Tuya? |
|
No problem. I've already found a working account and fixed this issue. It'll be in the update. |
|
I found an interesting project: Could be useful for adding support for Smart Life accounts, maybe. |
|
Thanks! I think we can finally accept this. |
|
Getting a stream without using a stupid dev account is, of course, a game changer for the Tuya API. |
|
Much appreciated 👍👍 |
|
Wow! Thanks for push to master, I can switch to. |


This PR adds comprehensive support for Tuya cameras in go2rtc, with both Tuya Cloud API and Tuya Smart API integration methods. It builds upon the previous PR that introduced initial Tuya integration.
Key Improvements
tuya://protocol instead ofwebrtc:for better clarity and separation of concernsresolution=hd|sd)This implementation has been tested with several Tuya camera models and provides a more robust experience while maintaining all functionality from the original PR.
Usage Examples
Closes #315 #1379