ZLMediaKit ubuntu初探


https://github.com/ZLMediaKit/ZLMediaKit

 

 

快速開始:
https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B

1.
請不要使用github下載zip包的方式下載源碼,務必使用git克隆ZLMediaKit的代碼,因為ZLMediaKit依賴於第三方代碼,
zip包不會下載第三方依賴源碼,你可以這樣操作:
#國內用戶推薦從同步鏡像網站gitee下載
git clone --depth 1 https://gitee.com/xia-chu/ZLMediaKit
cd ZLMediaKit
#千萬不要忘記執行這句命令
git submodule update --init


2.
切換分支到dev,因為只有dev分支才有webrtc的支持
列出分支
git branch -a
切換到dev
git checkout dev


3. 直接使用腳本編譯
./build_for_linux.sh

問題:1.
shell腳本報錯:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory

https://blog.csdn.net/yamaxifeng_132/article/details/71105311

windows編輯的bash傳到了linux下,windows下是dos方式,linux下是bash方式結尾

vim或者vi打開
:set ff
可以看到:
fileformat=dos

修改:
:set ff=unix

再次:set ff查看
fileformat=unix


問題:2.
會提示srtp找不到

最新libsrtp庫的編譯與測試方法
https://blog.csdn.net/cgs1999/article/details/89704359

git clone https://github.com/cisco/libsrtp.git
cd libsrtp

  ./configure
支持webrtc
  ./configure --enable-openssl

make
測試編譯結果
make runtest
sudo make install

 

4. 再次運行腳本./build_for_linux.sh進行編譯
編譯完成的程序在
ZLMediaKit/release/linux/Debug下

 

5. 運行測試
cd ZLMediaKit/release/linux/Debug
./MediaServer
程序啟動失敗,請修改配置文件中端口號后重試

sudo ./MediaServer


推流:
//rtsp push
ffmpeg -re -i "./test.264" -vcodec h264 -acodec aac -f rtsp -rtsp_transport tcp rtsp://192.168.192.141/live/test

//rtmp push
ffmpeg -re -i "./test.264" -vcodec h264 -acodec aac -f flv rtmp://192.168.192.141/live/test


拉流查看
ffplay -i rtsp://192.168.192.141/live/test -fflags nobuffer

ffplay -i rtmp://192.168.192.141/live/test -fflags nobuffer


//延時
采用vlc或者或者別的播放器是無法查看延時的,為了卡頓,音視頻同步等,會做buff處理,用ffplay會好點

 

效果如下截圖:

rtmp

 

rtsp

另:

采用rtsp推流,rtmp拉流,或者rtmp推流,rtsp拉流也是可以的

 

 

webrtc

注意:前期如果編譯libsrtp的時候沒有開啟openssl,此處會crash,重新編譯就好

 

打開2個頁面實現音視頻通信,選擇對應的分辨率
https://192.168.192.141/webrtc/

一個push
https://192.168.192.141/index/api/webrtc?app=live&stream=test&type=push
一個play
https://192.168.192.141/index/api/webrtc?app=live&stream=test&type=play

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM