树莓派搭建RTMP服务进行本地推流、拉流
371 字
2 分钟
树莓派搭建RTMP服务进行本地推流、拉流
演示直播间: https://live.bilibili.com/1983876
运行环境 debian9 arm nginx-1.16.0 nginx-http-flv-module ffmpeg(选用)
相关地址:
https://github.com/winshining/nginx-http-flv-module/blob/master/README.CN.md
nginx的服务器的搭建
安装nginx的依赖库
sudo apt-get updatesudo apt-get install libpcre3 libpcre3-devsudo apt-get install openssl libssl-dev编译环境补充
sudo apt-get install -y curl build-essential make gcc libpcre3 libpcre3-dev libpcre++-dev zlib1g-dev libbz2-dev libxslt1-dev libxml2-dev libgd2-xpm-dev libgeoip-dev libgoogle-perftools-dev libperl-dev libssl-dev libcurl4-openssl-dev配置并编译nginx 使用nginx的默认配置,添加nginx的rtmp模块。
./configure --with-http_ssl_module --add-module=nginx-http-flv-module的目录make(加-jx可以提高编译速度,x为核心数,看你设备的cpu核心数了。如你是8核的,那么就是make -j8)
sudo make install运行测试nginx 测试配置文件是否正常
/usr/local/nginx/sbin/nginx -t提示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful运行命令
/usr/local/nginx/sbin/nginx就可以启动nginx了
其他常用命令
-t 检查配置文件是否正确-s reload 重启nginx服务-s stop 停止nginx服务-V 查看nginx版本信息和添加的模块信息。注意这个V是大写的。
注意:以后所有的命令都在/usr/local/nginx目录运行,也nginx配置文件的相对目录。
配置rtmp
nginx.conf里加入
rtmp { server { listen 1935; #监听的端口 chunk_size 4000; application live { #rtmp推流请求路径 live on; hls on; hls_path /home/hls; #临时储存视频切片缓存的地方 hls_fragment 5s; } }}后面就可以进行推流测试咯。
可以用ffmpeg推流,很好用!
若推流地址
rtmp://127.0.0.1:1935/live/xx即播放地址
rtmp://127.0.0.1:1935/live/xx随后可用VLC等播放器查看效果》》
文章分享
如果这篇文章对你有帮助,欢迎分享给更多人!














