WebRTC 远程视频几秒后冻结

Gia*_*ran 5 android webrtc webrtc-android webrtc-ios exynos

我在 android 和 iOs 之间调用时使用 SurfaceViewRenderer 显示远程视频轨道时遇到问题(android <-> android 和 ios<->ios 也可以工作)

Android 上的远程视频视图会在几秒钟后冻结,但音频仍然有效(iOS 没问题)。

可能是iOS的H264编解码器引起的问题,但我按照最新的代码进行解码和编码PeerConnection,所以我仍然卡在这里。

下面是我的代码:

创造PeerConnectionFactory:

 PeerConnectionFactory.initialize(
                PeerConnectionFactory.InitializationOptions.builder(activity.getApplicationContext())
                        .setEnableInternalTracer(true)
                        .setEnableVideoHwAcceleration(true, true)
                        .createInitializationOptions());
Run Code Online (Sandbox Code Playgroud)

解码和编码

 private void tryingToCreatePeerConnectionFactory(EglBase eglBase) {
        final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
        final DefaultVideoEncoderFactory encoderFactory = new DefaultVideoEncoderFactory(eglBase.getEglBaseContext(), true, true);
        final DefaultVideoDecoderFactory decoderFactory = new DefaultVideoDecoderFactory(eglBase.getEglBaseContext());
        peerConnectionFactory = PeerConnectionFactory.builder().setOptions(options).
                setVideoDecoderFactory(decoderFactory).
                setVideoEncoderFactory(encoderFactory).
                createPeerConnectionFactory();
    }
Run Code Online (Sandbox Code Playgroud)

SDP内容

v=0
o=- 3807425029370800822 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video
a=msid-semantic: WMS ARDAMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 9 102 0 8 105 13 110 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:pTq5
a=ice-pwd:EVfiXQOe4/G/01ezOXYv1fzB
a=ice-options:trickle renomination
a=fingerprint:sha-256 A3:D1:0B:D4:9F:A9:ED:C5:D2:94:04:F3:91:07:6F:FD:68:71:4C:7B:CA:87:3F:AB:34:B5:F3:7E:82:0B:42:77
a=setup:active
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:9 G722/8000
a=rtpmap:102 ILBC/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:3210082304 cname:PPyVOHEaYgrfSyKM
a=ssrc:3210082304 msid:ARDAMS ARDAMSa0
a=ssrc:3210082304 mslabel:ARDAMS
a=ssrc:3210082304 label:ARDAMSa0
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 127
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:pTq5
a=ice-pwd:EVfiXQOe4/G/01ezOXYv1fzB
a=ice-options:trickle renomination
a=fingerprint:sha-256 A3:D1:0B:D4:9F:A9:ED:C5:D2:94:04:F3:91:07:6F:FD:68:71:4C:7B:CA:87:3F:AB:34:B5:F3:7E:82:0B:42:77
a=setup:active
a=mid:video
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:3gpp:video-orientation
a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 H264/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=fmtp:96 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640c1f
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 H264/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 red/90000
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:127 ulpfec/90000
a=ssrc-group:FID 2423939598 98025098
a=ssrc:2423939598 cname:PPyVOHEaYgrfSyKM
a=ssrc:2423939598 msid:ARDAMS ARDAMSv0
a=ssrc:2423939598 mslabel:ARDAMS
a=ssrc:2423939598 label:ARDAMSv0
a=ssrc:98025098 cname:PPyVOHEaYgrfSyKM
a=ssrc:98025098 msid:ARDAMS ARDAMSv0
a=ssrc:98025098 mslabel:ARDAMS
a=ssrc:98025098 label:ARDAMSv0
Run Code Online (Sandbox Code Playgroud)

更新 我们找到了这个问题的原因,由于未知的原因,Android端接收到的数据变低并且再也没有上升,这就是视频被冻结的原因

以下是视频冻结时收到的日期值

getBytesInInterval= 6091
Run Code Online (Sandbox Code Playgroud)

但我不知道为什么会发生

有人对我的问题有建议吗?任何回应将不胜感激。

小智 1

更新

我已经找到了这个问题的解决方案,伙计。根本原因来自于 iOS 尺寸,每个视频编解码器(解码/编码)的分辨率应该缩小,冻结帧的情况就会消失。

请更新 iOS 端的此代码

static let videoResolutionsStaticValues = [ "640x480", "960x540", "1280x720" ]
static let videoCodecsStaticValues = [ "H264", "VP8", "VP9" ]
Run Code Online (Sandbox Code Playgroud)