ue4-linux-running-webrtc

— 2021-8-10 补充—–
chrome://webrtc-internals/
可以查看当前浏览器的webrtc连接情况,方便查看debug

前置环境

Pixel Streaming in Linux containers

Linux上运行UE4像素流PixelStreaming

nvidia-container-toolkit

  • docker(docker)
  • nvidia驱动
  • nvidia-smi

adamrehn这个作者主要讲 ue4适配在linux中,其实源码的ue4 在编译后是可以在linux上跑的

主要通过 ue4-docker(python) 来打包 ue4的编译环境

docker build 来打包环境 和编译好的二进制文件 合并为一个镜像 就是pixel-stream-linux

以下面为dockerfile为例子

adamrehn/ue4-full:4.25-pixelstreaming 是 ue4-docker 生成的打包的环境

adamrehn/ue4-runtime:18.04-cudagl10.2 是在docker hub中存在的 运行环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#在包含引擎工具和像素流的虚幻引擎容器映像中执行构建
FROM adamrehn/ue4-full:4.25-pixelstreaming AS builder

#克隆或复制你的虚幻项目的源代码在这里,例如:
RUN git clone --progress --depth 1 https://github.com/user/project.git /tmp/project
# or:
COPY --chown=ue4:ue4 . /tmp/project

#创建并打包我们的虚幻项目

#(为了简洁起见,我们使用ue4cli,但我们也可以直接调用RunUAT)
WORKDIR /tmp/project
RUN ue4 package

复制打包文件到容器图像,其中包括CUDA,但不包括任何虚幻引擎组件
FROM adamrehn/ue4-runtime:18.04-cudagl10.2
COPY --from=builder --chown=ue4:ue4 /tmp/project/dist/LinuxNoEditor /home/ue4/project

#启用NVIDIA驱动程序所需的NVENC视频编码API
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES},video

#创建一个指向libvideo -encode.so路径的符号链接。1将被挂载,因为UE4似乎忽略了LD_LIBRARY_PATH

#(将“ProjectName”替换为你实际的虚幻项目的名称)
RUN ln -s /usr/lib/x86_64-linux-gnu/libnvidia-encode.so /home/ue4/project/ProjectName/Binaries/Linux/libnvidia-encode.so

安装成功的标准

运行 docker run –rm –gpus all nvidia/cuda:11.0-base nvidia-smi 有结果就可以

目前有两种方式来运行实例程序

  1. 打包dockerfile来运行

在上面的docker引用

  1. 使用命令

    docker run –rm -ti –network=host –gpus=all adamrehn/pixel-streaming-example-project:4.25 -PixelStreamingIP=192.168.11.20 -PixelStreamingPort=8888 -RenderOffScreen -ForceRes -ResX=1920 -ResY=1080

以上是 ue4后台

如果不需要外放访问,不需要考虑上面 STUN,SDUN这些都是 nat外网穿透的服务

后面只要启动SignallingWebServer 也是就是ue安装目录

\Epic Games\UE_4.26\Engine\Source\Programs\PixelStreaming\WebServers\SignallingWebServer

启动中效果有问题详细解释我在github 上提了issue https://github.com/adamrehn/pixel-streaming-linux/issues/53

在修改cirrus.js后就可以解决

// let playerId = msg.playerId; 解析为数字
    let playerId = parseInt(msg.playerId);
    delete msg.playerId; // no need to send it to the player
    let player = players.get(playerId);

webrtc关联的内容补充如下

参考这篇博文https://www.cnblogs.com/chyingp/p/sdp-in-webrtc.html

对于 webrtc spd内容的解读后对照着看了 SignallingWebServer/run.bat 服务的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
v=0
o=- 4274722770078417046 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1 2
a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:R2GR
a=ice-pwd:jo3amy6z8ly9guu6xeyC0rwf
a=ice-options:trickle
a=fingerprint:sha-256 C0:7D:CF:1E:FC:D1:DD:CD:83:38:C7:5D:8F:0D:0E:0F:2A:F6:B0:97:49:FF:98:4A:10:07:5C:94:80:81:B1:2A
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=recvonly
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:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 122 102 121 127 120 125 107 108 109 35 36 124 119 123 118 114 115 116 37
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:R2GR
a=ice-pwd:jo3amy6z8ly9guu6xeyC0rwf
a=ice-options:trickle
a=fingerprint:sha-256 C0:7D:CF:1E:FC:D1:DD:CD:83:38:C7:5D:8F:0D:0E:0F:2A:F6:B0:97:49:FF:98:4A:10:07:5C:94:80:81:B1:2A
a=setup:actpass
a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/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=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 VP9/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 profile-id=0
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 VP9/90000
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=fmtp:100 profile-id=2
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:122 VP9/90000
a=rtcp-fb:122 goog-remb
a=rtcp-fb:122 transport-cc
a=rtcp-fb:122 ccm fir
a=rtcp-fb:122 nack
a=rtcp-fb:122 nack pli
a=fmtp:122 profile-id=1
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 transport-cc
a=rtcp-fb:102 ccm fir
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f;x-google-start-bitrate=10000;x-google-max-bitrate=20000
a=rtpmap:121 rtx/90000
a=fmtp:121 apt=102
a=rtpmap:127 H264/90000
a=rtcp-fb:127 goog-remb
a=rtcp-fb:127 transport-cc
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f;x-google-start-bitrate=10000;x-google-max-bitrate=20000
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=127
a=rtpmap:125 H264/90000
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 transport-cc
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f;x-google-start-bitrate=10000;x-google-max-bitrate=20000
a=rtpmap:107 rtx/90000
a=fmtp:107 apt=125
a=rtpmap:108 H264/90000
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 transport-cc
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f;x-google-start-bitrate=10000;x-google-max-bitrate=20000
a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108
a=rtpmap:35 AV1X/90000
a=rtcp-fb:35 goog-remb
a=rtcp-fb:35 transport-cc
a=rtcp-fb:35 ccm fir
a=rtcp-fb:35 nack
a=rtcp-fb:35 nack pli
a=rtpmap:36 rtx/90000
a=fmtp:36 apt=35
a=rtpmap:124 H264/90000
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 transport-cc
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f;x-google-start-bitrate=10000;x-google-max-bitrate=20000
a=rtpmap:119 rtx/90000
a=fmtp:119 apt=124
a=rtpmap:123 H264/90000
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 transport-cc
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f;x-google-start-bitrate=10000;x-google-max-bitrate=20000
a=rtpmap:118 rtx/90000
a=fmtp:118 apt=123
a=rtpmap:114 red/90000
a=rtpmap:115 rtx/90000
a=fmtp:115 apt=114
a=rtpmap:116 ulpfec/90000
a=rtpmap:37 flexfec-03/90000
a=rtcp-fb:37 goog-remb
a=rtcp-fb:37 transport-cc
a=fmtp:37 repair-window=10000000
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:R2GR
a=ice-pwd:jo3amy6z8ly9guu6xeyC0rwf
a=ice-options:trickle
a=fingerprint:sha-256 C0:7D:CF:1E:FC:D1:DD:CD:83:38:C7:5D:8F:0D:0E:0F:2A:F6:B0:97:49:FF:98:4A:10:07:5C:94:80:81:B1:2A
a=setup:actpass
a=mid:2
a=sctp-port:5000
a=max-message-size:262144

下面是其他日志 目前前端只需要简单的js来实现

1
2
3
4
5
6
7
8
9

{
"type": "iceCandidate",
"candidate": {
"candidate": "candidate:2859681617 1 udp 2113937151 4ffffdaa-0101-4122-a4fb-b6c4c308d3e5.local 54016 typ host generation 0 ufrag R2GR network-cost 999",
"sdpMid": "0",
"sdpMLineIndex": 0
}
}