ubuntu22.10 ffmpeg-webrtc push-pull stream srs environment construction

1. Compile ffmpeg-webrtc
2. Openssl, opus, x264 configuration
3. Compile srs
4. Test
4.1 push stream end
4.2 pull stream end
5. Interaction and sdp

Recently, I saw the dynamics posted by Mr. Yang, so I have a taste of it.

1. Compile ffmpeg-webrtc
ffmpeg-webrtc official website: https://github.com/ossrs/ffmpeg-webrtc
pull ffmpeg-webrtc code:

git clone -b feature/rtc-muxer https://github.com/winlinvip/ffmpeg-webrtc.git

The configuration here requires openssl, opus, x264 see below

./configure --enable-muxer=rtc --enable-openssl --enable-version3 --enable-libx264 --enable-gpl --enable-libopus
make -j10

Two, openss, opus, x264
configuration configure openssl

sudo apt update
sudo apt install build-essential checkinstall zlib1g-dev
wget https://www.openssl.org/source/openssl-3.0.7.tar.gz
tar -xf openssl-3.0.7.tar.gz
cd openssl-3.0.7
./config --prefix=/usr/ --openssldir=/usr/ shared zlib
make
make test
make install
cd /etc/ld.so.conf.d/
nano openssl-3.0.7.conf

Compiling ffmpeg-webrtc will report an error openss < 3.0. In fact, I checked the logs in detail and found that openssl was not found, so that the official ffmpeg can be found. Here, special configuration is required: put the three libcrypto.pc in /usr/lib64/pkgconfig
/ Copy the three files libssl.pc openssl.pc to /usr/lib/pkgconfig/,

sudo cp /usr/lib64/pkgconfig/* /usr/lib/pkgconfig/
pkg-config update
sudo ldconfig

Reference: https://www.yundongfang.com/Yun224517.html

Compile x264, get the library from the website
http://www.videolan.org/developers/x264.html
directly apt-get install x264 under ubuntu22.10, ffmpeg-webrtc can’t find it, download the source code here and install it, and you can find it.
Open the downloaded x264 source code and execute

./configure --enable-shared --enable-static --disable-asm 
make
make install

install opus

sudo apt-get install libopus-dev

3. Compile srs
and pull the srs code:
srs, the version requires SRS version 5.0.153 or higher, or 6.0.43 or higher.

https://github.com/ossrs/srs

After compiling srs, run:

./objs/srs -c conf/rtc2rtmp.conf

4. Test
Run:
ffmpeg_g -re -i ~/git/srs/trunk/doc/source.flv -vcodec libx264 -profile:v baseline -r 25 -g 50 -acodec libopus -ar 48000 -ac 2 -f rtc " http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream” The
above input file is the test file in the srs package.
You can also use your own file. Note that it must be x264 library, opens encoding, baseline mode, and it cannot only contain video without audio, but also the main pixel format. The pixel format supported by baseline is limited.
4.1 Streaming end:

ffmpeg -re -i westlife.mp4 -vcodec libx264 -pix_fmt yuv420p -profile:v baseline -r 25 -g 50 -acodec libopus -ar 48000 -ac 2 -f rtc "http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream"

Among them, the streaming end can also use the WHIP of the webpage, but the test here is ffmpeg-webrtc.
4.2 Streaming end:
After testing, ffplay of ffmpeg-webrtc cannot pull WHIP stream, it should be that this part of the code is not perfect. Restricted by conditions, the delay will be measured later, and a hole should be dug first.
http://localhost:8080/players/whep.html?autostart=true
Please add a picture description 5. Interaction and sdp
Look at the interaction process between ffmpeg streaming terminal and srs:

[rtc @ 0x55816580bec0] WHIP: Init ice_arq_max=5, ice_arq_timeout=30, dtls_arq_max=5, dtls_arq_timeout=50 pkt_size=1500
[rtc @ 0x55816580bec0] WHIP: SDP offer=1048B, answer=1040B, ufrag=ods0t720, pwd=32B, transport=udp://192.168.100.245:8000
[rtc @ 0x55816580bec0] WHIP: ICE STUN ok, url=udp://192.168.100.245:8000, username=ods0t720:c2bf2fab, req=80B, res=-11B, arq=5
[rtc @ 0x55816580bec0] WHIP: DTLS handshake done=1, arq=0, srtp_material=60B
[rtc @ 0x55816580bec0] WHIP: SRTP setup done, suite=AES_CM_128_HMAC_SHA1_80, key=30B
[rtc @ 0x55816580bec0] WHIP: Create RTP muxer OK, buffer_size=4096, max_packet_size=1484
Output #0, rtc, to 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream':

The ffmpeg streaming terminal interacts with the sdp of srs:

[rtc @ 0x5615e784dec0] WHIP: Init ice_arq_max=5, ice_arq_timeout=30, dtls_arq_max=5, dtls_arq_timeout=50 pkt_size=1500
[rtc @ 0x5615e784dec0] Failed to request url=http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream, offer: v=0
o=FFmpeg 4489045141692799359 2 IN IP4 127.0.0.1
s=FFmpegPublishSession
t=0 0
a=group:BUNDLE 0 1
a=extmap-allow-mixed
a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111
c=IN IP4 0.0.0.0
a=ice-ufrag:1ac08523
a=ice-pwd:fb55f4f4d99d240fa65c2adfec5e7c24
a=fingerprint:sha-256 84:67:F7:27:AE:00:74:71:AA:EF:42:E1:B8:85:78:C9:6D:02:CB:F8:83:07:79:1F:4F:79:F8:1B:0A:5F:7C:C7
a=setup:active
a=mid:0
a=sendonly
a=msid:FFmpeg audio
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=ssrc:492341693 cname:FFmpeg
a=ssrc:492341693 msid:FFmpeg audio
m=video 9 UDP/TLS/RTP/SAVPF 106
c=IN IP4 0.0.0.0
a=ice-ufrag:1ac08523
a=ice-pwd:fb55f4f4d99d240fa65c2adfec5e7c24
a=fingerprint:sha-256 84:67:F7:27:AE:00:74:71:AA:EF:42:E1:B8:85:78:C9:6D:02:CB:F8:83:07:79:1F:4F:79:F8:1B:0A:5F:7C:C7
a=setup:active
a=mid:1
a=sendonly
a=msid:FFmpeg video
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:106 H264/90000
a=fmtp:106 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001e
a=ssrc:2806541432 cname:FFmpeg
a=ssrc:2806541432 msid:FFmpeg video

Guess you like

Origin blog.csdn.net/weixin_43466192/article/details/130660488