• OrangePI通过ffmpeg和nginx把摄像头输出为rtmp


    首先安装点基础套件

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

    从源码编译安装ffmpeg

    以上命令已经安装了发布版的ffmpeg,不过如果有需要,可以按照源码版的编译安装

    git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
    cd ffmpeg
    sudo ./configure --enable-shared --prefix=/usr/local/ffmpeg
    make
    sudo make 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配置文件

    nano /usr/local/nginx/conf/nginx.conf
    
    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;
            }
        }
    }
    
    

    写 systemd 配置文件

    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
    

    启动

    systemctl enable nginx
    systemctl restart nginx
    systemctl status nginx
    

    推送

    # 摄像头采集推送
    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
    
  • 相关阅读:
    在线课堂小项目
    在线课堂后端代码梳理
    .net调试exe或dll文件的反编译工具:dnSpy
    dnSpy反编译调试工具如何调试dll文件
    当前标识(IZFKXM52396ECSZ\iusr_iis)没有对“C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files”的写访问权限。
    把Json字符串转化为对应的类
    SQL Server 2008 R2定期自动备份、自动删除过期备份文件【转】
    Java 将HTML转为XML E
    C# 将HTML转为XML E
    MySQL删除重复数据
  • 原文地址:https://www.cnblogs.com/DragonStart/p/12151452.html
Copyright © 2020-2023  润新知