树莓派3服务器-搭建NGINX流服务器
树莓派3服务器-搭建NGINX流服务器
说明:
- 介绍如何搭建NGINX流服务器用于ffmpeg测试推流和拉流
步骤:
- 安装依赖
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
- 下载Nginx和nginx-rtmp-module源码
mkdir ~/tools
cd ~/tools
wget http://nginx.org/download/nginx-1.23.1.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/refs/tags/v1.2.2.tar.gz v1.2.2.tar.gz
- 解压和编译
tar -zxvf nginx-1.23.1.tar.gz
cd nginx-1.23.1
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-1.2.2
make
sudo make install
- 修改nginx配置文件,添加以下内容
sudo vim /usr/local/nginx/conf/nginx.conf
- 增加内容
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}
- 启动nginx+rtmp流媒体服务器
sudo /usr/local/nginx/sbin/nginx
- 测试推流, rtmp://localhost:1935/live
ffmpeg -re -i /Users/jack/test.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/live
使用vlc访问, 选择file -> open network -> 填写地址rtmp://localhost:1935/live, 既可以实现拉硫
安装GStreamer
sudo apt-get update
#安装 GStreamer
sudo apt-get install gstreamer1.0-tools
#安装 GStreamer 扩展组件
sudo apt-get install libgstreamer1.0-0 libgstreamer1.0-0-dbg libgstreamer1.0-dev liborc-0.4-0 liborc-0.4-0-dbg liborc-0.4-dev liborc-0.4-doc gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-alsa gstreamer1.0-doc gstreamer1.0-omx gstreamer1.0-plugins-bad gstreamer1.0-plugins-bad-dbg gstreamer1.0-plugins-bad-doc gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-base-dbg gstreamer1.0-plugins-base-doc gstreamer1.0-plugins-good gstreamer1.0-plugins-good-dbg gstreamer1.0-plugins-good-doc gstreamer1.0-plugins-ugly gstreamer1.0-plugins-ugly-dbg gstreamer1.0-plugins-ugly-doc gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-x libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-bad1.0-dev libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev
- usb摄像头推流
gst-launch-1.0 -v v4l2src device=/dev/video0 ! 'video/x-raw, width=1024, height=768, framerate=30/1' ! queue ! videoconvert ! omxh264enc ! h264parse ! flvmux ! rtmpsink location='rtmp://localhost:1935/live live=1'
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号