amazon-kinesis-video-streams-webrtc-sdk-c
amazon-kinesis-video-streams-webrtc-sdk-c copied to clipboard
[QUESTION] KVS Webrtc startup delay about 20s on Raspberry Pi4
Hello guys,
I installed KVS Webrtc C SDK 1.7.3 on RPI4 (4Go RAM). I'm running the Gst Master example on it. I developed a web viewer based on the JS SDK example.
Actually, I get a startup delay of ~20 seconds to get the video on the viewer side. After that, the latency is very low. Still the same thing with the console playback.
How can I reduce this startup delay? 1- In the bench folder, we mention this note : Optimize startup latency from ~9s to ~80ms (only for the first viewer). How to implement that?
2- In the wiki page, we mention that we could use a pre-generated certificates to reduce the startup latency.
I already generated an openssl certificate through this command:
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
Then I hardcoded the key and crt values and I pointed to them in the initializePeerConnection() function in Common.c as mentioned in the wiki.
configuration.certificates[0].pCertificate = pSampleConfiguration->certificates[0].pCertificate; configuration.certificates[0].pPrivateKey = pSampleConfiguration->certificates[0].pPrivateKey;
It doesn't work.
3- Is it essentiel to use AWS IoT certificate to get a better performance?
Any help please? Thanks.
Hello, Any update about this thread?
Have you looked at the verbose logging output to see where it seems to be stuck for that time? If you post them here (both master and viewer side is ideal), attach as a file please don't dump the contents in the comment then I can take a look and see what's going on.
Closing due to no response.
Hello @hassanctech, Sorry, I was on vacation. I see that @niyatim23 closed this issue. Can I reopen it or I have to open a new thread?
Reopening
hello @hassanctech
AWS Region: Paris (UE-WEST-3)
Master:
- HW: based on RPI4 (4Go RAM) with a custom camera (Digitized PAL video). It's connected to a 4G router which acts as an OpenVPN client. The ping between the client and the VPN server is 50ms.
- OS: Buster 10, Kernel: Linux 5.10.103
- SW: KVS Webrtc C SDK 1.7.3 based on Gstreamer example (Modified file is attached kvsWebRTCClientMasterGstreamerSample.txt), pipeline:
"-e autovideosrc ! queue ! videoconvert ! videorate ! video/x-raw ! \ x264enc bframes=0 speed-preset=veryfast byte-stream=TRUE tune=zerolatency ! \ video/x-h264,stream-format=byte-stream,alignment=au,profile=baseline ! tee name=t ! queue leaky=1 ! \ appsink sync=TRUE emit-signals=TRUE name=appsink-video t. ! queue leaky=1 ! filesink location= file.mkv t. ! queue leaky=1 ! h264parse ! rtph264pay pt=96 ! udpsink port=5080 host=10.8.0.1"
- APPLICATION: Record video locally on the equipment, stream webRTC for displaying, stream UDP to the server for recording
(even when streaming only, the issues still the same)
Viewer:
Viewer 1: Web application (Angular/Javascript) based on amazon-kinesis-video-streams-webrtc-sdk-js example.
Viewer 2: KVS WebRTC test page Viewer
ISSUE 1: Startup delay During the tests: Master -> Viewer 1: Startup: 16 secs => TEST1 FILES Master -> Viewer 2: Startup: 22 secs => TEST2 FILES
ISSUE 2: Sometimes, the stream is not sent from the Master to the Viewer => TEST3 FILE
Thanks for your support. kvsWebRTCClientMasterGstreamerSample.txt
Hello AWS, Any update please?
Any update?
Hello, Still no response. How to get an official support from AWS?
Hello @gharbit , Going through your logs, particularly in test3_no_video.txt it appears that you're connecting the signaling client very closely to when you're sending the sdp offer from the viewer. The design of the signaling client is that it should always be connected to reduce latency and avoid missing sdp offers. Is your master always connected to the signaling service?
Hi @jdelapla, Actually, I have a flag in my system, when it turns on, a trigger is sent to the viewer to start, and immediatly the whole kvsWebRTCClientMasterGstreamerSample is executed.
For the first issue (startup delay), I see that initializePeerConnection takes more than 5 seconds and the whole display between 10 and 20 seconds. In wiki page, it's described how to reduce that. I generated certifcates but it doesn't work.
For the second issue (stream not sent to the viewer), I did multiple capture tests, and the problem is that master doesn't receive the offer SDP and candidates from viewer. I described the issue here with log files: https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/issues/148
Is the SDP offer being missed because the UDP packet is being dropped? Or because the SDK is tossing the SDP offer? If the UDP packet is being erroneously dropped because of network than that is a condition outside our scope.
Additionally, from your VERBOSE logs we see that several debug messages (very noisy ones) are missing, and you may not actually be on 1.7.3
I installed the SDK master branch on June, The 1.7.3 was merged with master on May.
For your question:
Is the SDP offer being missed because the UDP packet is being dropped? Or because the SDK is tossing the SDP offer?
I don't know, that's why I opened this thread. I don't think that's a network issue, because I have another running UDP sockets and I receive 100% of packets without any errors.
How to further debug this issue? Is it possible to synchronize the SDP offer send/receive between master/viewer or to send it twice?
Hi, I checked the logs shared in the issue in the JS SDK as well as here, it seems like the Master (WebRTC SDK) is working as intended.
To debug further, please check if the viewer's connection is working. Use chrome://webrtc-internals/ on Chrome. Look for connectionstatechange
after starting the master and the viewer. If the state is not connected
when your master and viewer are both running, it means your viewer was not able to connect to your master and that is why the master does not receive the offer that your viewer sends
@gharbit ,
Anything to add or updates?
I am also facing the same issue sometimes master is not receiving the sdp offer from the viewer, tried sending multiple sdp offer in an interval of 2 secs to just check whether any sdp offer is reached but all retry attempts fails, any solution or fix for the same?
A few suggestions:
- Make sure the master and viewer are in the same region.
- Check if the network is stable to receive the offer.