OrangePI ffmpeg by the camera and output nginx rtmp

First install basic set point

sudo apt install -y ffmpeg libx264-dev libssl-dev yasm cmake

Ffmpeg installed from source

The above command has been installed release version of ffmpeg, but if necessary, can be installed in accordance with the source code version of the compiler


git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
sudo ./configure --enable-shared --prefix=/usr/local/ffmpeg
make
sudo make install

Compile and install nginx

sudo git clone https://github.com/arut/nginx-rtmp-module.git
sudo wget http://nginx.org/download/nginx-1.16.1.tar.gz
sudo tar -xvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
sudo  ./configure --prefix=/usr/local/nginx  --add-module=../nginx-rtmp-module  --with-cc-opt="-Wimplicit-fallthrough=0"
make -j4
make install

nginx configuration file

user www-data;
worker_processes auto;
pid /tmp/nginx.pid;

events {
  worker_connections 768;
  # multi_accept on;
}

rtmp {
    server {
        listen 1335;
        application rtmp {
            live on;
            max_connections 1024;
        }
        application zbcs {
            live on;
            record off;
        }
        application hls{
            live on;
            hls on;
            hls_path /rtmp/;
            hls_fragment 1s;
        }
    }
}

Write systemd configuration files

mkdir /usr/lib/systemd/system/
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx optimized HTTP server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/tmp/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/bin/kill -HUP $MAINPID
ExecsTOP=/usr/bin/kill -s QUIT $MAINPID
privateTmp=true

[Install]
WantedBy=multi-user.target

start up

systemctl enable nginx
systemctl restart nginx
systemctl status nginx

Push

# 摄像头采集推送
ffmpeg -i /dev/video0  -s 320x240 -f flv -an rtmp://127.0.0.1:1335/rtmp/1

# 视频文件推送
ffmpeg -stream_loop -1 -i cutb.mp4 -s 320x240 -f flv -an rtmp://127.0.0.1:1335/rtmp/1

Guess you like

Origin www.cnblogs.com/DragonStart/p/12151452.html