Skip to content
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

Question about RTSP Stream and ONVIF #414

Closed
idanny76 opened this issue Jan 1, 2022 · 163 comments
Closed

Question about RTSP Stream and ONVIF #414

idanny76 opened this issue Jan 1, 2022 · 163 comments
Labels

Comments

@idanny76
Copy link

idanny76 commented Jan 1, 2022

I am using a TruVision NVR that has 8 channels. The performance is not as I would like. Having to run all 8 cameras on the low stream RSTP. If I have the High RSTP some cameras will not work, because of low resources. I am trying to figure this all out. Question: Will it affect the NVR if I am also using the YI Home app at the same time? By having the NVR pulling stream from the cameras at the same time as the app also sending stream to the Yi app make the cameras overload?

I got the NVR free from my brother and just wanted to have the longer recording storage free. But the Yi app has good functionality that the NVR does not. The PTZ function on the NVR does not work. I would also like to have the NVR record on 1080p, but I guess thats too much to ask for. Any suggestion or help will greatly be appreciated, thank you.

@roleoroleo
Copy link
Owner

I am using a TruVision NVR that has 8 channels. The performance is not as I would like. Having to run all 8 cameras on the low stream RSTP. If I have the High RSTP some cameras will not work, because of low resources. I am trying to figure this all out. Question: Will it affect the NVR if I am also using the YI Home app at the same time? By having the NVR pulling stream from the cameras at the same time as the app also sending stream to the Yi app make the cameras overload?

Yes, but only while you watch the stream on the app.
If the cam is connected to the app but you don't watch the stream it should not be a problem.
AFAIK a single full hd stream from the cam works properly.
Check if the nvr opens more than one stream at the same time.

I got the NVR free from my brother and just wanted to have the longer recording storage free. But the Yi app has good functionality that the NVR does not. The PTZ function on the NVR does not work. I would also like to have the NVR record on 1080p, but I guess thats too much to ask for. Any suggestion or help will greatly be appreciated, thank you.

If you connectec the cam as ONVIF (not only as RTSP) the PTZ "should" work.
Should because ONVIF is not a good standard (IMHO).
I implemented the ptz support in the onvif daemon but other users noticed problems.

@idanny76
Copy link
Author

idanny76 commented Jan 6, 2022

I really appreciate you taking the time to reply to something not related to the firmware. I have the cameras connected as ONVIF and RSTP and the PTZ is not working. I am not sure if you are familiar with the Truvision NVR. I can upload settings screenshots if you have time or are willing to take a look. If not, thats ok... I can keep playing around with the settings to see why the low resources and bad NVR performance. It might just be a low end crappy NVR that says can handle 8 cameras and not be true. It might be that these cameras do no have the hardware ability even with the modded firmware to perform very well with RTSP and ONVIF.

@roleoroleo
Copy link
Owner

When you write ONVIF and RTSP you mean both?
So 2 connections?
You should connect the cam only with ONVIF; ONVIF will use RTSP to get the stream.

Please send me the screenshots of your settings.

I use a chinese NVR with my 4 cams and it works correctly, so the cam should not be a problem.

@idanny76
Copy link
Author

idanny76 commented Jan 8, 2022

When you write ONVIF and RTSP you mean both? So 2 connections? You should connect the cam only with ONVIF; ONVIF will use RTSP to get the stream.

Please send me the screenshots of your settings.

I use a chinese NVR with my 4 cams and it works correctly, so the cam should not be a problem.

Both ONVIF and RSTP are on, but the NVR is only pulling the ONVIF. If I turn the RSTP off, the ONVIF does not work. I have it set to provide both high and low quality stream. The only way to get low quality is by switching the channel on the camera setup from 1 to 2 for low quality. Here are the screenshots of the Yi-Hack settings and pictures of the NVR settings
Screenshot 2022-01-08 at 15-54-56 Backyard - configurations
Screenshot 2022-01-08 at 15-54-26 Backyard - status
IMG_20220108_155624
IMG_20220108_155639
IMG_20220108_155723
IMG_20220108_155741
IMG_20220108_155754
IMG_20220108_155802
IMG_20220108_155814
IMG_20220108_155950
IMG_20220108_160031
.

@idanny76
Copy link
Author

idanny76 commented Jan 8, 2022

PTZ for some reason does not work on the NVR. I have change the settings to low quality on all 8 cameras... TL-Hi, Video Quality Highest, Camera stream resolution low 640x360 and I can view all 8. Then less than an hour later the camera stream feed will be frozen or blacked out. The NVR is a TruVision NVR 11 model is TVN1108S with a 2TB hard drive. If I try 1080P on just one camera I start having issues. I would have loved to record all cameras at 1080p.

@roleoroleo
Copy link
Owner

Both ONVIF and RSTP are on, but the NVR is only pulling the ONVIF. If I turn the RSTP off, the ONVIF does not work.

This is correct.
NVR setup is ok. It should work.

I have change the settings to low quality on all 8 cameras... TL-Hi, Video Quality Highest, Camera stream resolution low 640x360 and I can view all 8. Then less than an hour later the camera stream feed will be frozen or blacked out. The NVR is a TruVision NVR 11 model is TVN1108S with a 2TB hard drive. If I try 1080P on just one camera I start having issues. I would have loved to record all cameras at 1080p.

Are you able to detect if the stream is frozen cam side or nvr side?
If you reboot the cam doest it restart?

@idanny76
Copy link
Author

idanny76 commented Jan 9, 2022

The stream is frozen on some and blackout on other on the NVR side. If I go on the Yi Home app or Kami app..... all the feeds work fine. If I reboot the NVR, it starts working good..... but it doesnt take long for the feed to start freezing on some and going black on others. According to the NVR specs.... it can handle up to 4/8/16 Full HD cameras in real-time (30fps). I am unsure if the NVR is defective, at fault or a poor quality NVR OR if the yi-hack firmware mod is at fault. Maybe I need to disable the recording to the SD Card and disable the feed to the YI Home servers?

Model : TVN-1108S-2T
Recording Capabilities

Up to 4/8/16 built-in PoE ports, for 4/8/16 Ch NVR'S
Plug-and-play camera installation
Continuous, motion/alarm triggered or scheduled recording modes
Event recording
Fully compatible with TruVision Navigator software
Audio recording with capable IP cameras
Reverse playback
Digital zoom on live and recorded video
Watermarking for legal video authentication
Free built-in DDNS service
Mobile apps allow you to connect remotely via smartphone or tablet to keep an eye on facilities, people or valuables
Start-up Wizards for quick and easy installation
40/80/160 Mbps for incoming streams respectively for 4/8/16 Ch NVR'S
Up to 6TB of storage � Familiar, user-friendly interface
Sub-stream for low bandwidth live viewing
2TB HDD included

Camera Support

Up to 4/8/16 Full HD cameras in real-time (30fps), for 4/8/16 Ch NVR'S
Supports 3rd-party cameras via ONVIF Profile S
TruVision VGA through 4K (8MPx) (indoor and outdoor)
TruVision 4/8/16 channel encoders
PTZ and dome camera control via mouse, front panel and IR remote control

@roleoroleo
Copy link
Owner

The stream is frozen on some and blackout on other on the NVR side. If I go on the Yi Home app or Kami app..... all the feeds work fine. If I reboot the NVR, it starts working good..... but it doesnt take long for the feed to start freezing on some and going black on others. According to the NVR specs.... it can handle up to 4/8/16 Full HD cameras in real-time (30fps). I am unsure if the NVR is defective, at fault or a poor quality NVR OR if the yi-hack firmware mod is at fault. Maybe I need to disable the recording to the SD Card and disable the feed to the YI Home servers?

The stream to the app is different from the rtsp stream. If the stream works on the app this doesn't mean that it also works on the rtsp client.
Try to disable recording to the sd and try to disable cloud services (just a try).
Swap space is enable or disable?
If you use vlc as a rtsp client, does the stream freeze?

@roleoroleo
Copy link
Owner

Are you able to set tcp as a transport protocol?

@roleoroleo
Copy link
Owner

Another try you can do.
Set the buffers to a higher value:

root@yi-hack-allwinner-v2:~# sysctl -w net.core.rmem_max=524288
net.core.rmem_max = 524288
root@yi-hack-allwinner-v2:~# sysctl -w net.core.rmem_default=524288
net.core.rmem_default = 524288
root@yi-hack-allwinner-v2:~# sysctl -w net.core.wmem_max=524288
net.core.wmem_max = 524288
root@yi-hack-allwinner-v2:~# sysctl -w net.core.wmem_default=524288
net.core.wmem_default = 524288

@idanny76
Copy link
Author

Are you able to set tcp as a transport protocol?

Yes, I have it set to Auto. But I opened the RSTP stream that was blacked out on the NVR in the VLC and the stream was good. So its nothing to do with the RSTP stream feed coming from the camera. I notice that if I go to the edit portion of the camera in the NVR and type the password again and apply..... the feed comes back up.

@idanny76
Copy link
Author

Another try you can do. Set the buffers to a higher value:

root@yi-hack-allwinner-v2:~# sysctl -w net.core.rmem_max=524288
net.core.rmem_max = 524288
root@yi-hack-allwinner-v2:~# sysctl -w net.core.rmem_default=524288
net.core.rmem_default = 524288
root@yi-hack-allwinner-v2:~# sysctl -w net.core.wmem_max=524288
net.core.wmem_max = 524288
root@yi-hack-allwinner-v2:~# sysctl -w net.core.wmem_default=524288
net.core.wmem_default = 524288

How or where do I set those buffer values? Thank you for taking the time to help me out. I haven't tried the disable the cloud and recording to the SD card, since the VLC stream from the camera was good.... basically letting me know it has to do with the NVR. If I dont have a authentication for the ONVIF..... anyone can access the feed if they have the IP and port number, correct?

@idanny76
Copy link
Author

So far its working..... Now the PTZ is not working. Do I need to do something in the Yi-Hack to allow the NVR to use PTZ?

@roleoroleo
Copy link
Owner

So far its working.....

What conf did you change?

Now the PTZ is not working. Do I need to do something in the Yi-Hack to allow the NVR to use PTZ?

PTZ should work automagically when the cam is configured as ONVIF.
But other users noticed problems with PTZ.
To test if it works, try Onvif Device Manager on Windows: the "official" testing software.

About buffer values, if you still need it, you can set them entering in the cam with a ssh connection (like putty), logging in with root user, and writing the commands above.

@idanny76
Copy link
Author

idanny76 commented Jan 11, 2022

PTZ is working now after reading and following the update you made on this link: #415

You might want to look into the update process through the web interface on the yi-hack. I did the update from the 0.4.1 to the 0.4.3 through the web interface and the PTZ lines you edited on the link above for the for the ipc_cmd.sh path were still on /tmp and not /home.

Do you think I should do a fresh install of the 0.4.3 in case other things might not have updated? Maybe the update may not have been done properly through the web interface and that might be causing some issues with the NVR?

@roleoroleo
Copy link
Owner

For this model, the update process overwrite the whole partition.
I don't know why this happens but I think that a fresh install doesn't fix the problem.
I will release a new version asap.

@idanny76
Copy link
Author

idanny76 commented Jan 11, 2022

For this model, the update process overwrite the whole partition. I don't know why this happens but I think that a fresh install doesn't fix the problem. I will release a new version asap.

Just fixed the outdoor camera by formatting the SD card, installing 0.4.2 first and then doing the web interface upgrade to the 0.4.3. Now the camera is working, but the PTZ file path did not update. Edited both files this time with the correct file path and PTZ is working. Online update is not updating the PTZ file path. I also did the update from 0.4.2 to 0.4.3 by removing the sd card and putting the new files and after the update completed..... path for PTZ was still wrong.

@idanny76
Copy link
Author

Got PTZ fixed, still need to test to see if NVR streams are freezing and blacking out. Before I get into the NVR testing.... I am trying to set the MQTT, everything seems to be pre-filled except the IP and Authentication. Do I use the same IP address for the Yi Camera? Client ID can be the camera name ex. backyard? For authentication use the same as the camera login?

I tried googling a tutorial online, but did not find one. Will keep looking. Thank you for all your help.... really appreciated.

@idanny76
Copy link
Author

idanny76 commented Jan 12, 2022

Just this morning all the live feed on the NVR was frozen except on two cameras. One of the cameras is a 720p Yi Home cam 27US 1.8.7.0F_201809191400 with alienatedsec/yi-hack-v5 firmware and the other still providing live feed was on of the 1080p on your firmware. I notice comparing those two feeds that the 720p cam live feed had almost no delays, but the 1080p was lagging behind.

I did read on your firmware description in regards to performance and you said "The performance of the cam is not so good (CPU, RAM, etc...). If you enable all the services you may have some problems. For example, enabling both rtsp streams is not recommended. Disable cloud is recommended to save resources." I have both feeds on, but the NVR is only using the low quality feed. Will having both on still consume camera resources even when the NVR is only accessing one?

The other thing I did notice this morning..... when the feeds are frozen or black, I went to the NVR and re-entered the camera password and the feed came back. I don't seem to be having that issue with the 720p Yi Home camera. This is the first time I notice that and I am guessing it has to do with better camera hardware? Or Firmware?

Not sure if by re-entering the password it reconnects to the camera by requesting the feed? I can also reboot the camera and feed comes back. If I reboot the NVR it also fixes the issue. Without restarting the NVR.... Rebooting the camera or re-entering the password restores feed.

@roleoroleo
Copy link
Owner

I did read on your firmware description in regards to performance and you said "The performance of the cam is not so good (CPU, RAM, etc...). If you enable all the services you may have some problems. For example, enabling both rtsp streams is not recommended. Disable cloud is recommended to save resources." I have both feeds on, but the NVR is only using the low quality feed. Will having both on still consume camera resources even when the NVR is only accessing one?

No, only if you consume them. And if you use only low res stream there must be no problem.

The other thing I did notice this morning..... when the feeds are frozen or black, I went to the NVR and re-entered the camera password and the feed came back. I don't seem to be having that issue with the 720p Yi Home camera. This is the first time I notice that and I am guessing it has to do with better camera hardware? Or Firmware?

I think the problem is that the NVR doesn't restart the stream when there is a corruption.
For example when the network goes down or when a frame is corrupted.

Not sure if by re-entering the password it reconnects to the camera by requesting the feed? I can also reboot the camera and feed comes back. If I reboot the NVR it also fixes the issue. Without restarting the NVR.... Rebooting the camera or re-entering the password restores feed.

What about the process when the screen is black?
Check if rRTSPServer is running when the cam is offline and if the connection is up:

ps | grep RTSP
netstat -anp | grep RTSP

Wait 10 seconds and try again the commands above to check if the process change the pid (dies and restarts).

Finally, kill rRTSPServer process, wait for the restart and check if it works.

@idanny76
Copy link
Author

idanny76 commented Jan 12, 2022

What about the process when the screen is black? Check if rRTSPServer is running when the cam is offline and if the connection is up:

ps | grep RTSP
netstat -anp | grep RTSP

Wait 10 seconds and try again the commands above to check if the process change the pid (dies and restarts).

Finally, kill rRTSPServer process, wait for the restart and check if it works.

in Putty I ran the command then waited 10 seconds, ran the command again, but nothing happened. After I killed the rRTSPServer process and camera came back from blacked out to live feed. Since the cameras are on WiFi there may be like you say a corruption or the feed went out or stopped for a second and the NVR did not restart the connection. How can I fix that? and what about the delay in video feed? Would the delay be solely on the WiFi connection?

login as: root
root@192.168.0.3's password:

                   _     _           _
               _ _|_|___| |_ ___ ___| |_
              | | | |___|   | .'|  _| '_|
              |_  |_|   |_|_|__,|___|_,_|
              |___|
 -----------------------------------------------------
  yi-hack for MStar platform - v. 0.4.3
 -----------------------------------------------------

/home/yi-hack # ps | grep RTSP
 1082 root      7:02 rRTSPServer
 1148 root      0:00 grep RTSP
/home/yi-hack # netstat -anp | grep RTSP
netstat: showing only processes with your user ID
tcp        0      0 0.0.0.0:554             0.0.0.0:*               LISTEN      1082/rRTSPServer
tcp        0      0 192.168.0.3:554         192.168.0.45:43414      ESTABLISHED 1082/rRTSPServer
netstat: /proc/net/tcp6: No such file or directory
udp     1408      0 0.0.0.0:6970            0.0.0.0:*                           1082/rRTSPServer
udp        0      0 0.0.0.0:6971            0.0.0.0:*                           1082/rRTSPServer
udp     1408      0 0.0.0.0:6972            0.0.0.0:*                           1082/rRTSPServer
udp        0      0 0.0.0.0:6973            0.0.0.0:*                           1082/rRTSPServer
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
/home/yi-hack # ps | grep RTSP
 1082 root      7:04 rRTSPServer
 2130 root      0:00 grep RTSP
/home/yi-hack # netstat -anp | grep RTSP
tcp        0      0 0.0.0.0:554             0.0.0.0:*               LISTEN      1082/rRTSPServer
tcp        0   1040 192.168.0.3:554         192.168.0.45:43414      ESTABLISHED 1082/rRTSPServer
netstat: /proc/net/tcp6: No such file or directory
udp     1408      0 0.0.0.0:6970            0.0.0.0:*                           1082/rRTSPServer
udp        0      0 0.0.0.0:6971            0.0.0.0:*                           1082/rRTSPServer
udp     1408      0 0.0.0.0:6972            0.0.0.0:*                           1082/rRTSPServer
udp        0      0 0.0.0.0:6973            0.0.0.0:*                           1082/rRTSPServer
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
/home/yi-hack # login as: root
/home/yi-hack # ps | grep RTSP
 1082 root      7:02 rRTSPServer
 1148 root      0:00 grep RTSP
/home/yi-hack # netstat -anp | grep RTSP
netstat: showing only processes with your user ID
tcp        0      0 0.0.0.0:554             0.0.0.0:*               LISTEN      1082/rRTSPServer
tcp        0      0 192.168.0.3:554         192.168.0.45:43414      ESTABLISHED 1082/rRTSPServer
netstat: /proc/net/tcp6: No such file or directory
udp     1408      0 0.0.0.0:6970            0.0.0.0:*                           1082/rRTSPServer
udp        0      0 0.0.0.0:6971            0.0.0.0:*                           1082/rRTSPServer
udp     1408      0 0.0.0.0:6972            0.0.0.0:*                           1082/rRTSPServer
udp        0      0 0.0.0.0:6973            0.0.0.0:*                           1082/rRTSPServer
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
/home/yi-hack # ps | grep RTSP
 1082 root      7:04 rRTSPServer
 2130 root      0:00 grep RTSP
/home/yi-hack # netstat -anp | grep RTSP
tcp        0      0 0.0.0.0:554             0.0.0.0:*               LISTEN      1082/rRTSPServer
tcp        0   1040 192.168.0.3:554         192.168.0.45:43414      ESTABLISHED 1082/rRTSPServer
Password: netstat: /proc/net/tcp6: No such file or directory
udp     1408      0 0.0.0.0:6970            0.0.0.0:*                           1082/rRTSPServer
udp        0      0 0.0.0.0:6971            0.0.0.0:*                           1082/rRTSPServer
udp     1408      0 0.0.0.0:6972            0.0.0.0:*                           1082/rRTSPServer

udp        0      0 0.0.0.0:6973            0.0.0.0:*                           1082/rRTSPServer
netstat: /proc/net/udp6: No such file or directory
netstat: /proc/net/raw6: No such file or directory
/home/yi-hack # kill 1082
/home/yi-hack #

@idanny76
Copy link
Author

I have it on low quality. Is the video feed delay due to WiFi? The 720p yi home has no delays, but all the 1080p Dome do.

@idanny76
Copy link
Author

I tried to set the higher buffer values, but it did not work. I notice it said yi-hack-allwinner-v2 and not MStar. I dont know if that has anything to do with it.

Set the buffers to a higher value:

root@yi-hack-allwinner-v2:# sysctl -w net.core.rmem_max=524288
net.core.rmem_max = 524288
root@yi-hack-allwinner-v2:
# sysctl -w net.core.rmem_default=524288
net.core.rmem_default = 524288
root@yi-hack-allwinner-v2:# sysctl -w net.core.wmem_max=524288
net.core.wmem_max = 524288
root@yi-hack-allwinner-v2:
# sysctl -w net.core.wmem_default=524288
net.core.wmem_default = 524288

@idanny76
Copy link
Author

I was trying to install alienatedsec / yi-hack-v5 on one of the 1080p Dome for testing. The reason was, because the only camera that has no delay and doesn't loose connection from the NVR is the 720p Yi Home 27US 1.8.7.0F_201809191400 and its on the Yi-Hack-v5. I copied the files to the SD card, but after a reboot.... the firmware was the same. Do you know if its possible?

@roleoroleo
Copy link
Owner

in Putty I ran the command then waited 10 seconds, ran the command again, but nothing happened. After I killed the rRTSPServer process and camera came back from blacked out to live feed.
Since the cameras are on WiFi there may be like you say a corruption or the feed went out or stopped for a second and the NVR did not restart the connection. How can I fix that?

You are using udp transport.
You should try to use tcp transport instead of udp. It should work better.

and what about the delay in video feed? Would the delay be solely on the WiFi connection?

Delay depends on many factors.

  • server buffering (live555).
  • client (for example using webrtc delay is very low).
  • network.

I have it on low quality. Is the video feed delay due to WiFi? The 720p yi home has no delays, but all the 1080p Dome do.

No, wifi is not a problem.

I tried to set the higher buffer values, but it did not work. I notice it said yi-hack-allwinner-v2 and not MStar. I dont know if that has anything to do with it.

MStar, Allwinner and Allwinner-v2 have the same software.

I was trying to install alienatedsec / yi-hack-v5 on one of the 1080p Dome for testing. The reason was, because the only camera that has no delay and doesn't loose connection from the NVR is the 720p Yi Home 27US 1.8.7.0F_201809191400 and its on the Yi-Hack-v5. I copied the files to the SD card, but after a reboot.... the firmware was the same. Do you know if its possible?

I don't know.

@idanny76
Copy link
Author

idanny76 commented Jan 14, 2022

I have tried everything except disable the recording to SD card and the cloud. I need the cloud, because the app is useful compare to other apps for android. I wanted to use the NVR to get more recording time and have a monitor setup with the cameras in constant view.

I did manage to get the RSTP link from two other cameras I have...... Hiseeu 5x Zoom that I bought from Amazon (https://www.amazon.com/gp/product/B08RHM6VF2). Those two cameras are also WiFi, but can be connected by Ethernet. I have those two cameras on WiFi and they work perfectly with the NVR. I get sound, PTZ, Zoom, Motion Detection without needing to do anything. I wish the Yi Dome camera with this firmware would work flawlessly.

Right now the Yi Dome cameras are loosing NVR connection / frozen feed... which turns into a black feed when refreshed. Does this have to do with the live555?

@roleoroleo
Copy link
Owner

roleoroleo commented Jan 14, 2022

Right now the Yi Dome cameras are loosing NVR connection / frozen feed... which turns into a black feed when refreshed. Does this have to do with the live555?

I don't know.

Did you set tcp transport?

Meanwhile I pulled out of the closet my old MISECU DVR.
Installed it yesterday.
At the moment it's working, I will check tomorrow.

@idanny76
Copy link
Author

Right now the Yi Dome cameras are loosing NVR connection / frozen feed... which turns into a black feed when refreshed. Does this have to do with the live555?

I don't know.

Did you set tcp transport?

Meanwhile I pulled out of the closet my old MISECU DVR. Installed it yesterday. At the moment it's working, I will check tomorrow.

Yes, all the connections are set to TCP. Mine too works fine for a certain amount of time. After I come back hours later.... the live feed is frozen and when I refresh I get a black screen. Even when I restart the NVR, there is a slight delay on the Yi Dome cameras and it seems to get worst as time passes. The same thing happened to the 720p Yi Home 27US version.... So I don't think its a firmware issue anymore. I have 1GB Fiber Internet connection with WiFi 6 router and can eliminate the WiFi or internet as a problem here.

The other two Hiseeu 5x Zoom cameras don't have a lag, freeze or any issues.... But that might be because of better hardware. I guess I will see if you experience the same issue or not. Will try to disable the cloud and sd card recording and see what happens.

@roleoroleo
Copy link
Owner

I will send you a feedback in a few days.

@idanny76
Copy link
Author

idanny76 commented Jan 14, 2022

I will send you a feedback in a few days.

I think you might want to take a look at this post on another Yi-Hack by TheCrypt0 . Just found it and will start looking at it now. Thank you for taking your valuable time to check this issue out. I know you do this on your free time and I greatly appreciated.

/TheCrypt0

@roleoroleo
Copy link
Owner

Does the server write something to stdout/stderr when an error happens and are those file descriptors redirected to a log file or something?

Yes, it prints to stdout/stderr and no, it's not redirected.

Or should I manually run the server and redirect output to a file?

Yes.

The SD card is needed for v5, not for MStar.

@tonitonae
Copy link

Thanks.

I will check if it breaks, although it has been working for the last 6 hours without a problem. I do not know why it crashed yesterday multiple times and not today (only change being the activation of ONVIF).

Regarding v5: do you know if I can directly upgrade from v4 or should I reset to stock firmware and then flash?

Thanks!

@roleoroleo
Copy link
Owner

Regarding v5: do you know if I can directly upgrade from v4 or should I reset to stock firmware and then flash?

No, sorry. I don't know.

@tonitonae
Copy link

Just in case anyone else guesses: yes, it is possible to upgrade from v4 to v5.

It has been running for 15 minutes with the provided RTPS server and seems to be working (we will see how stable it is).

I wanted to check the rtsp_server_yi that @roleoroleo shared some comments before (the one for v5) but it does not work for me (Yi Outdoor camera). If manually run from the command line (after killing the other one, if not it would not bind to 554) it seems to be running but when I try to connect with, say, VLC, it just outputs that a client connects and, after a few seconds, that it disconnects. Nothing more, and VLC does not get any image.

Can I do something else to try to debug why it is not working on my camera?

Thanks!

@tonitonae
Copy link

Thanks.

I will check if it breaks, although it has been working for the last 6 hours without a problem. I do not know why it crashed yesterday multiple times and not today (only change being the activation of ONVIF).

Regarding v5: do you know if I can directly upgrade from v4 or should I reset to stock firmware and then flash?

Thanks!

Well... It just broke. Around 10 hours working without issue and it crashed 10 minutes after I added a second camera to frigate :/

I just killed the server and the watchdog run it again and everything started working again. The thing is that the process does not die and thus the watchdog does not restart it. It somehow hangs and stops sending data through the feed (or the data is corrupted, I am not sure, I have to analyze the errors on the client...

@roleoroleo
Copy link
Owner

I have to analyze the errors on the client...

If you are able to find the problem we could create a special watchdog.
For example checking the sockets or the cpu usage of the process.

@tonitonae
Copy link

Yes. I am running it now interactively to see if something is outputted when the error takes place.

I will keep digging into it.

@tonitonae
Copy link

I am seeing many messages saying:

write_buffer failed

These messages are not timestamped, but I guess they have appeared at the same time I have seen errors in the client.

However, the server, for now, has not crashed. Clients have been able to reconnect...

Do you know what could have caused the error message? Maybe a memory problem? Is swap enabled? Should it be?

@tonitonae
Copy link

I have been peeking into the code and it seems that this message is emitted by the TcpConnection class when it can not write to the buffer. RtspConnection inherits from TcpConnection so it would make sense that the call in line 202 of RtspConnection.cpp is the one causing the error.

This problem, from what I see, can arise either when buffer is empty (size < index, given a default value for index of 0) or when the buffer is full.

I would like to debug this a little further. Can you give me some clues on how to cross-compile for the OS in the camera? I do not have a Windows machine (just Mac and Linux). Is that ok?

I have, however, a very crazy hypothesis of why this is happening. Yesterday the camera was working fine for the whole day. The problems started when the sun started to set and it got darker in that room. I programmed a crontab job in the camera to kill the server every hour and have it respawn by the watchdog. It did, but the server hang almost immediately every single time... until the sun has risen this morning... I do not know the internals of how the video is being grabbed from the kernel memory but: would it be possible that there is some difference when the camera switches to night view? A buffer of different size or even location?

I know about correlation and causality, and I will monitor the whole day again, but my problems the last couple of days started by night, when there was no light.

Any help to cross-compile the server with some additional printfs is welcome.

Thanks!

@roleoroleo
Copy link
Owner

I would like to debug this a little further. Can you give me some clues on how to cross-compile for the OS in the camera? I do not have a Windows machine (just Mac and Linux). Is that ok?

It's ok. I'm using a Debian 9 vm.
https://github.com/roleoroleo/yi-hack-MStar#build-your-own-firmware

To build only rtsp_server_yi run this script:
https://github.com/roleoroleo/yi-hack-MStar/blob/master/src/rtsp_server_yi/compile.rtsp_server_yi
It's already configured to call the cross-gcc.

About your hypothesis, it's possible.
When the room is darker enough, the cam turns on ir lights and moves the ir filter.
In this moment, the cam produces a larger frame. Maybe there is is a problem...

@tonitonae
Copy link

OK. Thanks. I will give it a try.

No crashes since this morning. It seems that it actually might be related to the ir filter...

I will update here with my findings.

Cheers!

@idanny76
Copy link
Author

idanny76 commented Mar 2, 2022

OK. Thanks. I will give it a try.

No crashes since this morning. It seems that it actually might be related to the ir filter...

I will update here with my findings.

Cheers!

Any progress or updates?

@tonitonae
Copy link

Hi @idanny76.

Sorry, this week has been impossible to me to have some time for this. My full time work and parenting leave me little spare time. I will try next week.

Just to update my experience: it varies; sometimes, it does not crash in a whole day, even with the IR changes when lights are out. Other times, it instantly crashes when I turn out the lights. I have a funny video in which the last frame is me turning the lights switch off :)

I will update as soon as I have something.

Cheers.

@TurboDuke77
Copy link

I also have problems with the RTSP stream, often I only have 10s of live video and then the stream freezes. I suspect it's also often when switching to night mode or when there is a lot of movement in front of the camera, e.g. a hand directly in front of the lens.

In the YI Home app, the video is stable. I use the y203c version for my Yi 1080p Home 4FUS camera.

@idanny76
Copy link
Author

idanny76 commented Apr 13, 2022

Is the NVR supposed to record also the Audio? I am not getting any Audio. Truvision NVR 11 Stream Type is grayed out and its only on Video and not Audio & Video. Not sure why.

@roleoroleo
Copy link
Owner

Yes, NVR should record also audio.
But I noticed that many nvrs are not compatible with some codecs.
Try to change alaw, ulaw, aac, etc...

@idanny76
Copy link
Author

idanny76 commented Apr 19, 2022

I contacted the Camera manufacturer and he says the NVR is also disabling audio in the cameras memory card. In the Yi Cameras I still get audio on the SD Cards, even do the NVR is not recording audio. But on my other Hiseeu PTZ cameras I do not get audio on the SD Card or NVR. Just when you think you have everything working..... you find something else. I didn't notice the NVR had not audio, because I don't usually need the audio and the audio for the live feed was working. But the other day I needed to hear the audio of some suspicious solicitors and the recorded video did not have audio.

Now I have an NVR that doesn't record audio and zero support information online on this brand. Interlogix TruVision NVR 11 (TVN 11). So much for an NVR.

@idanny76
Copy link
Author

idanny76 commented Apr 19, 2022

Here is the Data Sheet https://static.interlogix.com/library/gsp-2612-nvr-11-data-sheet-web-v2.pdf for the NVR and it says "Supports 3rd-party cameras via ONVIF Profile S". Looking at some information on Profile S.... It seems it only records AAC audio. I am testing that now. Just switched one Yi camera to AAC.

Edit: Just tested it and not getting audio on AAC.

@roleoroleo
Copy link
Owner

Does audio work with vlc?

@idanny76
Copy link
Author

Does audio work with vlc?

Yes, sound works in VLC..... Its the NVR. For some reason all the options to Record audio and Stream type are grayed out for all cameras in the NVR. On the Stream type if it wasn't grayed out there is an option for video and audio. The Record Audio has an option to put a check mark, but it is also grayed out. The only thing I could try is reset the whole NVR ans start from scratch, but I have a feeling it will not solve it.
IMG_20220419_131812

@roleoroleo
Copy link
Owner

Sorry, I don't know how to help you.
Maybe other users.

@idanny76
Copy link
Author

No worries.... Just wanted to see if you knew something about it. I can still get audio on the Yi Cam SD cards. The other brand cameras are not recording audio on the SD card and I was told by the seller that the NVR was disabling it on the cameras. So, it seems the NVR is not so good after all.

@idanny76
Copy link
Author

Is there a reason why the feed of the Yi Dome goes from 1080p to 640p and not 720p?

@roleoroleo
Copy link
Owner

It's the standard configuration made by yi: high and low resolution.

@idanny76
Copy link
Author

Sorry, I don't know how to help you. Maybe other users.

I decided to look into this again of why the NVR was not recording Audio. I finally found the reason why my NVR is not recording audio, but the video only. The NVR I have only Supports 3rd-party cameras via ONVIF Profile S. So I started looking into ONVIF Profile S and it only streams video and audio and only records video. ONVIF Profile G records and stores video and audio. The NVR is limiting the audio recording if its a third party camera. Picture attached shows the different ONVIF profiles and what they allow or support.

https://www.cctvcameraworld.com/onvif-security-camera-compatibility
Screenshot 2022-06-29 at 14-37-39 Understanding ONVIF and its limitations
/

@idanny76
Copy link
Author

It's the standard configuration made by yi: high and low resolution.

I don't know how much you know about the NVR's. It's upsetting that the NVR I have only supports recording video and not Audio for third party cameras. The only audio I get from this NVR on third party cameras is live streaming. Do you know of any hacks or mods for NVR's that are out there?

@roleoroleo
Copy link
Owner

I don't know of any hacks.

Copy link

github-actions bot commented Apr 4, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Apr 4, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants