实现FFmpeg流媒体服务器的目的是为了学习使用,在真正的工作当中是不需要自己配置服务器的,会有专门的人员进行配置
服务器的准备
1.硬件:我使用的是腾讯云服务器,花了88大洋买了一年
2.软件:
需要现在如下软件
nginx: https://github.com/nginx/nginx/releases
我下载的版本是1.17.8
rtmp: https://github.com/arut/nginx-rtmp-module/releases
我下载的版本是1.2.1
pcre: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.zip
我下载的版本是8.38
zlib: https://github.com/madler/zlib
我下载的版本是1.2.11
openssl: https://github.com/openssl/openssl
我下载的版本是1.1.1c原先是用的是1.0.2u但是有问题
![](https://img.haomeiwen.com/i16249515/ebd9dde72cb7bad3.png)
安装下载的软件
下载完成后依次到解压的根目录下执行如下命令
pcre:./configure -> make -> make install
zlib: ./configure -> make -> make install
rtmp : 只需要下载不需要安装
openssl: ./config --prefix=pwd
/libs -> make -> make install
nginx: ./auto/configure --add-module=/lib/nginx/nginx-rtmp-module-1.2.1 --with-openssl=/lib/nginx/openssl-OpenSSL_1_1_1c ->make ->make install
安装完如上配置后还需要复制一个文件
cd到rtmp目录下的test,输入命令cp nginx.conf /usr/local/nginx/conf/
复制nginx.conf 复制到nginx的安装目录
启动服务器
![](https://img.haomeiwen.com/i16249515/e47d4213df898775.png)
到/usr/local/nginx/sbin目录下执行
启动:./nginx
停止:./nginx -s stop
启动成功后不会有任何提示,启动失败才会有提示
比如启动错误: xxx.so 找不到,
可以输入 ldd LD_LIBRARY_PATH
把SO库都链接过来
测试服务器
下载FFmpeg然后解压,然后cd的解码目录的bin下面,输入如下命令
测试命令:.\ffmpeg.exe -re -i 1111.mp4 -vcodec libx264 -acodec aac -f flv rtmp://服务器地址/myapp/mystream
![](https://img.haomeiwen.com/i16249515/f3529fe169c7701c.png)
网友评论