关于ubuntu:Ubuntu2004构建ZLMediaKit流媒体服务框架含webrtc

2次阅读

共计 1455 个字符,预计需要花费 4 分钟才能阅读完成。

最近的工作须要架设一台流媒体服务器用于后续的业务开发。在 git 上找到了很好的开源框架 ZLMediaKit,依照页面教程操作之后,总是不能胜利编译 webrtc 模块,通过各种搜寻和尝试,总算是搭建胜利,现把过程分享如下,也给本人留个记录。
零碎环境:Ubuntu20.04.4

1. 获取代码

代码从 git 获取,如果没装置 git,须要执行

sudo apt-get intall git
cd /opt
#拉取我的项目代码
git clone https://github.com/ZLMediaKit/ZLMediaKit.git
#国内用户举荐从同步镜像网站 gitee 下载 
git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit
cd ZLMediaKit
#不要忘了这句命令
git submodule update --init

2. 装置编译器

# 装置 gcc
sudo apt-get install build-essential
#装置 cmake
sudo apt-get install cmake

3. 依赖库

1.openssl 装置编译

# 如果之前装置了能够先卸载:apt -y remove openssl
cd /opt
#从 git 下载
git clone https://github.com/openssl/openssl.git
#如果 git 下载太慢或者连贯有问题(比方我),能够到 gitee 下载
git clone https://gitee.com/mirrors/openssl.git
#上面的顺次执行
mv openssl openssl-src && cd openssl-src
./config --prefix=/opt/openssl
make -j4
sudo make install
cd /opt/openssl && cp -rf lib64 lib

2.libsrtp 装置编译

cd /opt
git clone https://gitee.com/mirrors/cisco-libsrtp.git
cd cisco-libsrtp
./configure --enable-openssl --with-openssl-dir=/opt/openssl
make -j4
sudo make install

4. 构建和编译 ZLMediaKit

cd /opt/ZLMediaKit
mkdir build
cd build
cmake .. -DENABLE_WEBRTC=true -DOPENSSL_ROOT_DIR=/opt/openssl -DOPENSSL_LIBRARIES=/opt/openssl/lib 
cmake --build . --target MediaServer

5. 补充操作

上一步操作执行后,运行服务胜利但没有 demo 页面,发现对应的 www 文件夹以及 ssl 证书并未放入指定目录,须要进行补充操作

# 把 www 文件夹复制到编译后的目录
cd /opt/ZLMediaKit
sudo cp -r www release/linux/Debug/
#把自带的 ssl 证书放到编译后的目录
sudo cp -r tests/default.pem release/linux/Debug/

6. 启动服务

cd /opt/ZLMediaKit/release/linux/Debug
#通过 - h 能够理解启动参数
./MediaServer -h
#以守护过程模式启动
./MediaServer -d &

之后浏览器关上 https:// 你的服务器 ip/webrtc 能够胜利推流拉流


以上流程亲测编译胜利且可用。
参考资料:官网 wiki,网络博客

正文完
 0