Closed KodeZ closed 6 years ago
In order to make the library easier for using, there is much regex using which could load much, especially for the function "GetMediaData". Thanks for your feedback, I will try to improve the problem.
To improve performance, there are 2 kind of way:
WITHOUT WRITING HARD DISK: Just now, I committed some code to improve performance, which lowers the use of regex and provide the API to disable the function of obtaining SPS,PPS,VPS periodically, please refer to complete_example.cpp. If you don't change USLEEP_UNIT(default 10,000), in my test case, it will take about 7-8%(user time+sys time) more than openRtsp. If you change USLEEP_UNIT to 13000, it will do as good as openRtsp. If you change USLEEP_UNIT to 15000, it will do better than openRtsp.
WITH WRITING HARD DISK In my old examples, it invokes "write" for every packet of data. You could lower the frequency of "write" to improve the performance. You could refer to the new "complete_example.cpp" which does well in my test case
Additional note: I assumed that there are 25 frames of video data and "1 frame 1 packet" in 1 second. So the interval between 2 frames is 1/25 second(40,000 us). According to "sampling theorem", the sampling period is 20,000us. And because the 'usleep' is not precise enough, in order to get stable data, myRtspClient set it 10,000us. That is USLEEP_UNIT.
I have been testing different rtsp clients. OpenRTSP obviously being one. Most of the ones I have tested do leave a lot to be desired, but this library is ticking a lot of boxes for me, as I need to run it on an embedded system.
As such, i have been doing some tests, and I am somewhat surprised by the result. It seems that this library is using more resources than OpenRTSP. I was expecting the opposite to be honest. In the default setup, openRTSP uses approx 0.1s user, 0.3s system on my laptop for 30s recording, while this library uses 0.3s user and 0.3s system. System seems to be a fraction lower with this library, but user time is certainly higher. By increasing the USLEEP_UNIT I can get it down to < 0.2s, but that comes with it's own set of issues too, see below.
I am also seeing some video corruption from my Reolink C1-pro camera, the lower part of the frame seems to break up. That situation seems to improve if I reduce USLEEP_UNIT and increase the buffer size, but my laptop should have more than enough umph to handle this. I have yet to figure out why. I get these errors:
So I am wondering what I am doing wrong here. I am sure that this library can work, but I am unable to do so it seems. I would be willing to help out with this and to get it working, but I don't know where to start really.