树莓派RTMP直播推流

1.安装FFmpeg

sudo apt-get install gcc g++ make cmake git
sudo apt-get install ffmpeg
sudo apt-get install libavutil-dev libswscale-dev libswresample-dev libavcodec-dev libavformat-dev libavdevice-dev libavfilter-dev

2.编译安装nginx-rtmp

sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev
sudo apt-get install libz-dev

wget http://nginx.org/download/nginx-1.19.10.tar.gz
git clone https://github.com/arut/nginx-rtmp-module.git
tar -xzvf nginx-1.19.10.tar.gz
mv nginx-rtmp-module/ nginx-1.19.10/
cd nginx-1.19.10/
./configure --prefix=/usr/local/nginx --add-module=./nginx-rtmp-module --with-http_ssl_module
make -j4 && sudo make install

3.修改nginx.conf

user  root;
worker_processes  1;

error_log  /tmp/nginx_error.log;
pid        /tmp/nginx.pid;

events {
    worker_connections  1024;
}

rtmp { 
    server {
        access_log off;
        listen 1935;
        timeout 10s;

        ping 10s;
        ping_timeout 10s;

        drop_idle_publisher 10s;
        idle_streams off;
        #直播
        application live {  
            live on;  
        }
 
        application hls {  
            live on;  
            hls on;  
            hls_path /tmp/hls;  
        } 
 
        #点播
        application vod {
            play /tmp/video;
    	}
 
    }  
}

4.rtmp推流

# 启动nginx
sudo /usr/local/nginx/sbin/nginx
# ffmpeg推流
ffmpeg -framerate 15 -video_size 640x480 -i /dev/video0 -vcodec h264_omx -f flv rtmp://127.0.0.1/live/camera
# ffplay播放
ffplay -i rtmp://127.0.0.1/live/camera
上一篇:surging 如何使用流媒体服务


下一篇:TSINGSEE青犀视频流媒体音视频系列解决方案(汇总篇)