安装ffmpeg,编译x264 安装ZLMediakit
参考https://blog.csdn.net/u013015301/article/details/140778199
因为这里需要的安装包都比较好找,不提供下载地址了,也可以联系作者提供
1、安装nasm
tar -xf nasm-2.14.tar.gz
cd nasm-2.14
./configure
make
make install
nasm -v
2、安装x264
tar -xf x264.tar
cd x264
mkdir -p /usr/x264/
./configure --prefix=/usr/x264/ --includedir=/usr/local/include --libdir=/usr/local/lib --enable-shared
make
make install
#配置环境变量
vim /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
source /etc/profile
pkg-config --libs x264
3、安装ffmpeg
tar -xf ffmpeg-7.0.2.tar.xz
cd ffmpeg-7.0.2
./configure --prefix=//usr/local/ffmpeg --enable-gpl --enable-libx264 --enable-shared --extra-ldflags=-L/usr/local/lib --extra-cflags=-I/usr/local/include
make
make install
#配置环境变量
vim /etc/profile
export PATH=$PATH:/usr/local/ffmpeg/bin
source /etc/profile
ffmpeg -version
#遇到报错xxx.so.xx: cannot open shared object file: No such file or directory
#解决方案
首先查找so所在位置
find / -name "libavdevice.so.60"
/usr/local/ffmpeg/lib/libavdevice.so.61
vim /etc/ld.so.conf
#添加lib的绝对路径
/usr/local/ffmpeg/lib/
ldconfig
4、安装cmake
tar -xf cmake-3.26.3.tar.gz
cd cmake-3.26.3
yum -y install openssl openssl-devel
./bootstrap
gmake
gmake install
make -version
5、安装ZLMediakit
unzip ZLMediaKit.zip
cd ZLMediaKit
mkdir build
cd build
cmake .. -DENABLE_WEBRTC=on
make -j 4
make install
cd ZLMediaKit/release/linux/Debug
./MediaServer -h
nohup ./MediaServer -d >nohup.log 2>&1 &
测试命令:
1、启动一个rtsp流
ffmpeg -re -stream_loop -1 -i /root/test.mp4 -c:v libx264 -preset veryfast -tune zerolatency -b:v 1500k -maxrate 1500k -bufsize 6000k -c:a aac -b:a 128k -f rtsp rtsp://127.0.0.1/live/test -rtsp_flags listen
2、查看是否是h264格式
ffprobe -v error -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 rtsp://your_stream_url