Closed DScrp closed 2 years ago
I tested the WebRTC/udp playback and confirmed that it works fine. Check if the UDP port is open properly.
And in my opinion, there is no big difference in connection speed between WebRTC/udp and WebRTC/tcp. The only difference is due to TCP slow start, which does not cause human perceptible initial connection delay (tens of milliseconds). If it's really because of tcp slow start, try changing the Congestion Control method to BBR.
https://airensoft.gitbook.io/ovenmediaengine/troubleshooting#5-3.-congestion-control-change-to-bbr
As you know, UDP does not have good quality in high definition because there are many environments with high packet loss.
Now I understand the problem. If I do not use video re-encoding, then everything works with UDP and TCP:
/usr/local/bin/ffmpeg -hide_banner -use_wallclock_as_timestamps 1 -stream_loop 0 -rtsp_transport udp -i rtsp://admin:password@192.168.1.101/Streaming/Channels/3 -vcodec copy -af "aresample=async=1:first_pts=0" -acodec aac -f flv -flvflags no_duration_filesize "rtmp://my.site:1936/camera-1/channel-3";
If i use video re-encoding, works only with TCP:
/usr/local/bin/ffmpeg -hide_banner -hwaccel cuda -use_wallclock_as_timestamps 1 -stream_loop 0 -rtsp_transport udp -i rtsp://admin:password@192.168.1.101/Streaming/Channels/3 -c:v h264_nvenc -b:v 2048k -bf 0 -af "aresample=async=1:first_pts=0" -acodec aac -f flv -flvflags no_duration_filesize "rtmp://my.site:1936/camera-1/channel-3";
What do I need to do to make everything work with UDP and TCP with re-encoding? Unfortunately, I need to use re-encoding. And according to my tests, the connection via UDP is established several times faster than via TCP. Therefore, I need to use re-encoding and the UDP protocol.
I can only guess the cause of your problem.
The only reason it plays fine with TCP but not with UDP is "packet loss". If you encode, I guess the bit rate of the keyframe will increase at the moment. (Isn't the bitrate of the original video rather lower than 2048k?) If even one packet out of dozens of packets constituting a frame is lost, the frame is discarded. And in your UDP environment, this is likely to happen frequently. And keyframe has a higher bit rate than other frames. And any live video can start playing from the moment it receives the keyframe. To verify this, try changing the bitrate to 500k. And take a closer look at what's happening in chrome://webrtc-internals/ in chrome.
It cannot happen that WebRTC/udp has several times faster initial connection than WebRTC/tcp. This would be a different matter. Maybe the test is wrong or there is something wrong with your network. But I think the most likely cause is the very long keyframe interval. Try setting the keyframe interval to 1 second with options like -g 30 .
If you use OvenMediaEngine's OriginMap, you can create a stream by pulling the rtsp stream. (What you are doing with ffmepg) This feature will make your system configuration simpler. https://airensoft.gitbook.io/ovenmediaengine/live-source/rtsp-pull-beta
Thank you. But now there is another problem. In desktop browsers and Android work fine with TCP and UDP. But in iOS video is not loading. Two same errors in console: Websocket network error: The operation couldn'r be completed (OSStatus error - 9807). Websocket network error: The operation couldn'r be completed (OSStatus error - 9807).
https://www.osstatus.com/search/results?platform=all&framework=all&search=9807 - about this errors on Apple site.
In Server.xml there are all SSL certificates in accordance with the manual https://airensoft.gitbook.io/ovenmediaengine/streaming/tls-encryption Tested on two different servers. I use SSL from Let's Encrypt.
This is an issue that cannot be reproduced in my testbed. If you ever set up a certificate, check if the Chain Cert and Domain Cert are correctly set separately. Does the Chain Cert contain a Domain Cert, or does the Domain Cert contain a Chain Cert?
I solved the problem. In Server.xml at
But there was a very strange problem with UDP. Now UDP works fine at desktop Safari and Firefox (MacOS), Firefox (Win), and mobile Android, iOS. But in Google Chrome and Edge UDP works only with VPN. But if switch transport to TCP, then everything works without VPN. Checked on computers with Windows and Mac. I can't understand what could be causing this problem. In javascript player debug i see events "connectionstatechange connecting" and after a few seconds "connectionstatechange disconnected". But as soon as I turn on the VPN and reload page, "connectionstatechange connecting" change to "connected". Or if i set TcpForce to "true". This problem only in Chrome and browsers on its engine.
Do you have any guesses as to what this might be? I am install OME on two servers, everywhere the result is the same. With UDP and Chrome not connecting, with VPN and UDP (or TCP or other browsers) - works fine. Sometimes it happens that it connects via UDP in Chrome (without VPN). But very, very rarely.
Logs:
[2022-03-21 21:11:23.307] I [SPRtcSig-T3334:2870496] Signalling | rtc_signalling_server.cpp:232 | New client is connected: <ClientSocket: 0x7f59f0001130, #34, Connected, TCP, Nonblocking, 111.222.333.444:7046>
[2022-03-21 21:11:23.641] I [SPRtcSig-T3334:2870496] Monitor | stream_metrics.cpp:114 | A new session has started playing #my.site#camera-12/channel-3 on the WebRTC publisher. WebRTC(1)/Stream total(1)/App total(1)
[2022-03-21 21:11:23.645] I [SPICE-U10000:2870500] ICE | ice_port.cpp:779 | Add the client to the port list: 111.222.333.444:7060 / Packet type : 0 GateType : 0
[2022-03-21 21:11:34.612] W [SPICE-U10000:2870500] ICE | ice_port.cpp:745 | Mismatched ufrag: P06a (ufrag in peer SDP: Y8uF)
[2022-03-21 21:11:34.612] I [SPICE-U10000:2870500] ICE | ice_port.cpp:783 | Update the client to the port list: to 111.222.333.444:7061 from 111.222.333.444:7060
[2022-03-21 21:11:34.613] I [SPRtcSig-T3334:2870496] Monitor | stream_metrics.cpp:114 | A new session has started playing #my.site#camera-12/channel-3 on the WebRTC publisher. WebRTC(2)/Stream total(2)/App total(2)
[2022-03-21 21:11:34.676] I [SPICE-U10000:2870500] ICE | ice_port.cpp:779 | Add the client to the port list: 111.222.333.444:7061 / Packet type : 0 GateType : 0
[2022-03-21 21:11:45.603] W [SPICE-U10000:2870500] ICE | ice_port.cpp:745 | Mismatched ufrag: bRtB (ufrag in peer SDP: P06a)
[2022-03-21 21:11:45.603] I [SPICE-U10000:2870500] ICE | ice_port.cpp:783 | Update the client to the port list: to 111.222.333.444:7062 from 111.222.333.444:7061
[2022-03-21 21:11:45.603] I [SPRtcSig-T3334:2870496] Monitor | stream_metrics.cpp:114 | A new session has started playing #my.site#camera-12/channel-3 on the WebRTC publisher. WebRTC(3)/Stream total(3)/App total(3)
[2022-03-21 21:11:45.669] I [SPICE-U10000:2870500] ICE | ice_port.cpp:779 | Add the client to the port list: 111.222.333.444:7062 / Packet type : 0 GateType : 0
[2022-03-21 21:11:56.600] I [SPRtcSig-T3334:2870496] Monitor | stream_metrics.cpp:114 | A new session has started playing #my.site#camera-12/channel-3 on the WebRTC publisher. WebRTC(4)/Stream total(4)/App total(4)
[2022-03-21 21:11:56.605] I [SPICE-U10000:2870500] ICE | ice_port.cpp:779 | Add the client to the port list: 111.222.333.444:7072 / Packet type : 0 GateType : 0
[2022-03-21 21:12:07.613] W [SPICE-U10000:2870500] ICE | ice_port.cpp:745 | Mismatched ufrag: 44/A (ufrag in peer SDP: T0bl)
[2022-03-21 21:12:07.613] I [SPICE-U10000:2870500] ICE | ice_port.cpp:783 | Update the client to the port list: to 111.222.333.444:7052 from 111.222.333.444:7072
[2022-03-21 21:12:07.614] I [SPRtcSig-T3334:2870496] Monitor | stream_metrics.cpp:114 | A new session has started playing #my.site#camera-12/channel-3 on the WebRTC publisher. WebRTC(5)/Stream total(5)/App total(5)
[2022-03-21 21:12:07.672] I [SPICE-U10000:2870500] ICE | ice_port.cpp:779 | Add the client to the port list: 111.222.333.444:7052 / Packet type : 0 GateType : 0
[2022-03-21 21:12:18.611] I [SPRtcSig-T3334:2870496] Monitor | stream_metrics.cpp:114 | A new session has started playing #my.site#camera-12/channel-3 on the WebRTC publisher. WebRTC(6)/Stream total(6)/App total(6)
[2022-03-21 21:12:18.613] I [SPICE-U10000:2870500] ICE | ice_port.cpp:779 | Add the client to the port list: 111.222.333.444:7050 / Packet type : 0 GateType : 0
[2022-03-21 21:12:28.732] W [SPICE-U10000:2870500] ICE | ice_port.cpp:745 | Mismatched ufrag: qYAe (ufrag in peer SDP: kNtL)
[2022-03-21 21:12:28.732] I [SPICE-U10000:2870500] ICE | ice_port.cpp:783 | Update the client to the port list: to 111.222.333.444:7054 from 111.222.333.444:7050
[2022-03-21 21:12:28.736] I [SPRtcSig-T3334:2870496] Monitor | stream_metrics.cpp:114 | A new session has started playing #my.site#camera-12/channel-3 on the WebRTC publisher. WebRTC(7)/Stream total(7)/App total(7)
[2022-03-21 21:12:28.794] I [SPICE-U10000:2870500] ICE | ice_port.cpp:779 | Add the client to the port list: 111.222.333.444:7054 / Packet type : 0 GateType : 0
Maybe the error is related to warning "Mismatched ufrag"? How can i fix this?
Try explicitly setting the server's network interface by setting the IP address instead of * in
<Publishers>
<WebRTC>
<IceCandidates>
<TcpRelay>xxx.xxx.xxx.xxx:3478</TcpRelay>
<TcpForce>true</TcpForce>
<IceCandidate>xxx.xxx.xxx.xxx:10000/udp</IceCandidate>
<TcpRelayWorkerCount>1</TcpRelayWorkerCount>
</IceCandidates>
</WebRTC>
<Publishers>
I have tried these settings. Does not work.
Hmm well, it looks like there's something unexpected about your network. It only works when you are connected to a VPN, so you should check the firewall or NAT on your PC when VPN is not connected. The server doesn't seem to be the problem. I'm running OME in various environments, but I've never experienced anything like that. I just checked that UDP plays fine in chrome too.
It seems like a good attempt to create an AWS EC2 instance and test it in a public IP.
There are no firewalls. I tried on three completely different computers with different operating systems: Win10 and MacOS. And the problem is only in Chrome browser. Desktop Firefox, Safari and mobile browsers works fine.
Would you like to check the websocket message(signaling) in your chrome like I captured? Is Answer SDP sent multiple times? Looking at the log you uploaded, after "New client is connected", "Add the client to the port list" should be printed only once, but it is strange that it is printed continuously. Answer SDP seems to be sent multiple times. Are those logs from testing on demo.ovenplayer.com?
I use my player based on OvenPlayer. If there was no connection within 10 seconds, then it connects again. Because of this, there are multiple connections in the logs. Now I have disabled this and the player connects only 1 time.
I check websocket message in Chrome:
{"command":"request_offer"}
{candidates: [{candidate: "candidate:0 1 UDP 50 xxx.xxx.xxx.xxx 10003 typ host", sdpMLineIndex: 0}] code: 200 command: "offer" id: 1221238068 peer_id: 0 sdp: "v=0\r\no=OvenMediaEngine 103 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE bEm5Mw Oa0oXx\r\na=group:LS bEm5Mw Oa0oXx\r\na=msid-semantic:WMS lrTzoutnUq1CSeBHGMvk8bAh7JmNfYj04ZED\r\na=fingerprint:sha-256 CE:D3:C6:AB:F9:F8:2F:19:DC:BD:D1:CD:DC:8D:34:11:F1:CC:48:48:FA:85:BC:9C:94:FD:9C:4F:5F:62:76:04\r\na=ice-options:trickle\r\na=ice-ufrag:QrNWfl\r\na=ice-pwd:Z1juGsrDXfPiFkobze9MB8xt4VUnNvwl\r\nm=video 9 UDP/TLS/RTP/SAVPF 100\r\nc=IN IP4 0.0.0.0\r\na=sendonly\r\na=mid:bEm5Mw\r\na=setup:actpass\r\na=rtcp-mux\r\na=msid:lrTzoutnUq1CSeBHGMvk8bAh7JmNfYj04ZED rqXyG2OsC9IpS83V74AR1MgtblPo05KjNhex\r\na=extmap:1 urn:ietf:params:rtp-hdrext:framemarking\r\na=rtpmap:100 H264/90000\r\na=fmtp:100 packetization-mode=1;profile-level-id=42e01f;level-asymmetry-allowed=1\r\na=ssrc:4091287708 cname:KYCDcTprWsqPIkfu\r\na=ssrc:4091287708 msid:lrTzoutnUq1CSeBHGMvk8bAh7JmNfYj04ZED rqXyG2OsC9IpS83V74AR1MgtblPo05KjNhex\r\na=ssrc:4091287708 mslabel:lrTzoutnUq1CSeBHGMvk8bAh7JmNfYj04ZED\r\na=ssrc:4091287708 label:rqXyG2OsC9IpS83V74AR1MgtblPo05KjNhex\r\nm=audio 9 UDP/TLS/RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\na=sendonly\r\na=mid:Oa0oXx\r\na=setup:actpass\r\na=rtcp-mux\r\na=msid:lrTzoutnUq1CSeBHGMvk8bAh7JmNfYj04ZED OzspXHE05TjVYhxaMUcoB6Gnilu4kJAQDCLF\r\na=rtpmap:101 OPUS/48000/2\r\na=fmtp:101 sprop-stereo=1;stereo=1;minptime=10;useinbandfec=1\r\na=ssrc:1354674223 cname:KYCDcTprWsqPIkfu\r\na=ssrc:1354674223 msid:lrTzoutnUq1CSeBHGMvk8bAh7JmNfYj04ZED OzspXHE05TjVYhxaMUcoB6Gnilu4kJAQDCLF\r\na=ssrc:1354674223 mslabel:lrTzoutnUq1CSeBHGMvk8bAh7JmNfYj04ZED\r\na=ssrc:1354674223 label:OzspXHE05TjVYhxaMUcoB6Gnilu4kJAQDCLF\r\n" type: "offer"
command: "answer" id: 1221238068 peer_id: 0 sdp: "v=0\r\no=- 894814847246516550 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE bEm5Mw Oa0oXx\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 100\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:ym+L\r\na=ice-pwd:24qISBPMJSRQTAq1wE190CKG\r\na=ice-options:trickle\r\na=fingerprint:sha-256 F4:5F:18:C4:38:6E:5C:79:95:DF:3C:FE:F4:4E:12:77:6A:AB:2D:D6:8A:4D:AC:4F:57:84:45:54:19:16:CA:22\r\na=setup:active\r\na=mid:bEm5Mw\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:100 H264/90000\r\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\nm=audio 9 UDP/TLS/RTP/SAVPF 101\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:ym+L\r\na=ice-pwd:24qISBPMJSRQTAq1wE190CKG\r\na=ice-options:trickle\r\na=fingerprint:sha-256 F4:5F:18:C4:38:6E:5C:79:95:DF:3C:FE:F4:4E:12:77:6A:AB:2D:D6:8A:4D:AC:4F:57:84:45:54:19:16:CA:22\r\na=setup:active\r\na=mid:Oa0oXx\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:101 OPUS/48000/2\r\na=fmtp:101 minptime=10;useinbandfec=1\r\n" type: "answer"
candidates: [{candidate: "candidate:3028854479 1 udp 2113937151 4477cb12-c843-4a96-90a3-361df27c5781.local 49542 typ host generation 0 ufrag ym+L network-cost 999" sdpMLineIndex: 0 sdpMid: "bEm5Mw" }] command: "candidate" id: 1221238068 peer_id: 0
Both my development environment and the commercial environment I run play fine with UDP. I tried to reproduce your problem, but I couldn't. Does it reproduce the same in https://demo.ovenplayer.com in your environment?
If you find the cause of the problem, please share it for all of us.
Yes, I've tried at https://demo.ovenplayer.com/ UDP works fine at desktop Safari and Firefox (MacOS), Firefox (Win), and mobile Android, iOS. But in Google Chrome and Edge UDP works only with VPN. But if switch transport to TCP, then everything works without VPN.
Hmm... Could it be an IPv6 related issue?
I was able to find an article like the one below. https://groups.google.com/g/discuss-webrtc/c/R3RMOblxdP8?pli=1
Would you like to try turning off IPv6 on Local PC once? I am not using IPv6 in my environment.
This is very similar to our case. Do you mean my local computer with Win10? I check my ip on site https://whatismyipaddress.com/ IPv6: Not detected. In Win10 i turn off Ipv6 too. But nothing has changed. Sometimes it works in Chrome, but very rarely. If you reload the page 10-20 times, it will connect in Chrome without VPN. Could this be related to my ISP?
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.
Hello. I used OME 12 before and could switch between UDP and TCP protocols. The UDP protocol was enabled by default and if i want enable TCP, i attaching the query transport=tcp to the existing WebRTC play URL. Everything worked fine. But now I installed OME 13.1 and can't switch to UDP.
When I use the following config everything works fine via TCP:
But the connection takes a long time and I would like to speed it up, as I did earlier on OME 12 and UDP protocol. But when I set TcpForce to false or delete this setting from Server.xml, the stream stops loading in player. I try it in OvenMediaPlayer, in my player and in https://demo.ovenplayer.com/ With TcpForce=true works fine. If change it to false - not working.
Logs:
How can I use UDP in my streams like I did in OME 12 and increase connection speed?