1.搭建网页服务器
先实现本地推流rtsp,vlc预览:
./rtsp-simple-server #window运行
ffmpeg -re -stream_loop -1 -i 3.mp4 -c copy -f rtsp rtsp://192.168.0.109:8554/live/test #window运行
2.编译zlmediakit(webrtc功能)
ubuntu20.04,gcc为9.4环境
#安装openssl
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -xvzf openssl-1.1.1k.tar.gz
sudo apt install -y zlib1g-dev zlib1g libperl-dev
cd openssl-1.1.1k
./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
sudop make
sudo make install
#安装libsrtp,由于gcc版本为9.4,下载2.5.0b版本不然会报错
wget https://github.com/cisco/libsrtp/archive/refs/tags/v2.5.0.tar.gz
tar -xvzf libsrtp-2.5.0.tar.gz
cd libsrtp-2.5.0/
./configure --enable-openssl --with-openssl-dir=/usr/local/openssl
sudo make -j8
sudo make install
#编译zlm源码
git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit
cd ZLMediaKit
git submodule update --init
mkdir build
cd build
cmake .. -DENABLE_WEBRTC=true -DOPENSSL_ROOT_DIR=/usr/local/openssl -DOPENSSL_LIBRARIES=/usr/local/openssl/lib
cmake --build . --target MediaServer
#运行
cd ../release/linux/Debug/
sudo ./MediaServer -d
ubuntu推流
#RTMP协议
ffmpeg -re -i 3.mp4 -vcodec h264 -acodec aac -f flv rtmp://127.0.0.1/live/test
浏览器打开http://192.168.0.62/,选择6。
url选择:http://192.168.0.62/index/api/webrtc?app=live&stream=test&type=play
其中192.168.0.62为流媒体服务器ip地址
#RTSP协议,禁止B帧输出
ffmpeg -re -stream_loop -1 -i 3.mp4 –bf 0 -c copy -f rtsp rtsp://192.168.0.62/live/test
需要在配置文件中设置 directProxy=0, ffmpeg 生成的 rtsp 流中不带 sps/pps 信息, webrtc 播放会有问题.
但是在IPC过来的数据流都是带有sps,pps信息的。
- finish:完成网页服务器的搭建,下篇准备实现网页的消息通信