guino / BazzDoorbell

124 stars 22 forks source link

Corrupted rtsp stream #87

Open jurasjo opened 1 year ago

jurasjo commented 1 year ago

Hi, I wonder if anybody has similar problem with his Tuya based WIFI camera. I have 3 similar cameras (NEDIS SmartLife Outdoor Camera) - https://nedis.com/en-us/product/security-safety/ip-security/outdoor/550671323/smartlife-outdoor-camera-wi-fi-hd-720p-ip65-internal-16gb-12-v-dc-night-vision-android-ios-silver-white?_ga=undefined I'm attaching the link to the screenshot: https://prnt.sc/qdfOiXpHIOuW

The problem is related only to the main rtsp stream (1920x1080). The rtsp substream always works. Video in Nedis App works normally but sometimes it has a problem to load and at the same time rtsp doesn't work as well. Issue started while camera were on "stock" firmware (2.10.6) and it is also the case now while hacked.

Somebody any idea what can be wrong?

guino commented 1 year ago

@jurasjo never seen that issue myself, but it seems like it could be due to wifi issues (bandwidth/reliability). I would make sure you're using RTSP over TCP also, but otherwise I have no other suggestions. Does the problem stay for awhile ? if so, does rebooting the device fix it ?

jurasjo commented 1 year ago

I use tp-link omada controller + 2 access points. I think signal/bandwidth/reliability shouldn't be an issue. Unless there is some incompatibility between omada and wifi modules in those cameras.

This issue occurs only during the day, never during the night. It may be connected to biggest bitrate during the day? I also have the fourth same/identical camera but with firmware 5.2.1 and that one works perfectly.

Sometimes it can last the whole day, sometimes it occurs for a while and it doesn't look like rebooting has big impact on it.

guino commented 1 year ago

@jurasjo while the image is bad (as on your screenshot) -- if you open the phone app, does it look the same or does it look correct ? If it looks the same then it's hardware/firmware issue, if it looks fine it's an issue with RTSP, Wifi or client.

Is the firmware 5.2.1 not available for upgrade on your older cameras ?

jurasjo commented 1 year ago

This kind of crappy stream occurs only while using RTSP (VLC, Frigate, Home assistant) and only on main stream. Sub stream always works. Image on the phone is correct. I would suspect some incompatibility with WIFI module connected to firmware 2.10.6.

There is no upgrade available. If I remember correctly those 3 cameras had the same base firmware and then there was an upgrade to 2.10.6 and the fourth one had different base firmware(I think 5.x.x) and went to 5.2.1.

guino commented 1 year ago

@jurasjo can you tell me which URL you're using: rtsp://IP:8554 or rtsp://IP:8554//Streaming/Channels/10x ? I assume it is the last one since that's the only way to access SubStream/MainStream. It it possible that your firmware has the old code for RTSP in it and we could try to enable that as there have been some reports or issues with the new style of RTSP (from ONVIF feature) -- you can post your ppsapp file and I can check it.

In any case just make sure you're using RTSP over TCP -- the default is UDP and is more prone to issues like that.

jurasjo commented 1 year ago

Hi I use rtsp://admin:admin@192.168.13.60:8554/Streaming/Channels/101 and /102. At this very moment main-stream doesn't work, sub-stream works and both HD and SD streams work in Mobile app.

I have attached ppsapp (from /home/app? if I'm recognizing correctly). ppsapp.tar.gz

jurasjo commented 1 year ago

And now cameras went to night mode(black-white) and all the streams works in HD ;) I have tried this command for all my cameras:

ffprobe rtsp://admin:admin@192.168.13.xx:8554/Streaming/Channels/101

and only the camera with version 5.2.1 is without any warning:Metadata: title : pps_rtsp Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1920x1080, 15 fps, 15 tbr, 90k tbn, 30 tbc Stream #0:1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s

Problematic ones even if are in "working" mode, outputs some warning about the RSTP steam:

[h264 @ 0x55a7e7995680] number of reference frames (1+2) exceeds max (2; probably corrupt input), discarding one Input #0, rtsp, from 'rtsp://admin:admin@192.168.13.63:8554/Streaming/Channels/101': Metadata: title : pps_rtsp Duration: N/A, start: 0.000000, bitrate: N/A Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 1920x1080, 12 tbr, 90k tbn, 180k tbc Stream #0:1: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s

Sometimes there is no warning/error but in most case there is one. So maybe your assumption about this "new style of RTSP (from ONVIF feature)" is the proper direction. Would be nice to sort it.

jurasjo commented 1 year ago

Have you had a chance to look into this file?

guino commented 1 year ago

@jurasjo sorry, I was traveling for the whole last week -- I'll take a look as soon as I have a chance.

jurasjo commented 1 year ago

Not a problem. I'm wondering what had changed that made it stop working(HD stream). All of those cameras at once. It worked on this firmware (2.10.6) for at least half a year.

guino commented 1 year ago

Try this patch with rtsp://IP:8555 - see if that RTSP version works better for you. firmware: ppstrong-c51-tuya2_teco2-2.10.6.20210814 md5: 9738e84be3de15bc99b65dcdf797946c snap/mjpeg.cgi address: 0x056e6b0 play.cgi address: 0x0571f94 offline+rtsp port 8555 patch: ppsapp-rtsp.zip

jurasjo commented 1 year ago

Thank you for your help and patience ;). So, I assume I have to follow this procedure: Here's how to patch ppsapp After the hack is installed: power off the device, remove the SD card and take it to a computer Go to https://www.marcrobledo.com/RomPatcher.js/ DO NOT CLICK ON CREATOR MODE Click ‘choose file’ in front of ‘ROM file’ and select the original ppsapp file under /home/app/ppsapp on the SD card (assuming you didn’t do anything to it since the hack was installed) VERIFY that the md5 value displayed matches the md5 from the list below (listed with the patch for your ppsapp) Click ‘choose file’ in front of ‘Patch file’ and select the zip file you downloaded from the list below Click ‘apply patch’ and save/download the file to the root of the SD card (the default file name will likely be ppsapp-rtsp) Rename the saved/downloaded file on the root of the SD card to ppsapp (make sure it has no .txt or any extension) — verify the size is exactly the same as the size of /home/app/ppsapp in the SD card (which should be a few megabytes) Properly eject/unmount the SD card from computer (i.e. windows using the tray icons, linux umount command, etc) Insert SD card to device and power it on Wait for it to boot - you likely will hear the startup sound 2 times. After the 2nd startup time you can try to view the rtsp feed under rtsp://ip:8554 (unless you're on 2.9.7 in which case you use the links provided with the patch). I have done also some online searching about the possible problem with Omada equipment and there may be some issue regarding WIFI settings. I have changed some settings and for some time it works as it should but it may be coincidence. I will set up my WIFI as it was previously, then I will wait for the stream to be corrupted and then I will apply fix you provided.

guino commented 1 year ago

@jurasjo Yes -- the only thing to note is that your rtsp URL will be rtsp://IP:8555 (NOT 8554)