zoukankan      html  css  js  c++  java
  • Mac下通过FFMpeg实现Android手机推流和播放

    一、Mac下搭建推流服务器(Nginx+RTMP+FFMpeg)

    安装x264

    git clone git://git.videolan.org/x264.git
    cd x264
    ./configure --enable-static --enable-shared
    make -j8
    sudo make install

    安装FFMpeg

    git clone git://source.ffmpeg.org/ffmpeg.git
    cd ffmpeg
    
    ./configure --enable-gpl --enable-nonfree --enable-pthreads --enable-libx264 --enable-libmp3lame
    make -j8
    sudo make install

    FFMpeg源码Xcode debug

    https://github.com/sfssqs/ffmpeg-xcode

    安装Nginx和nginx_rtmp_module插件

    git clone https://github.com/nginx/nginx.git
    git clone https://github.com/arut/nginx-rtmp-module.git
    cd nginx-v.XXX
    ./configure --add-module=/path/to/nginx-rtmp-module --with-openssl=/path/to/openssl-v.XXX
    make -j8
    make install

     安装VCL

    http://get.videolan.org/vlc/3.0.1/macosx/vlc-3.0.1.dmg

     配置RTMP Server文件,nginx.conf

    rtmp {
        server {
            # 监听端口
            listen 1935; 
            chunk_size 4000;
    
            application rtmplive {
               live on;
               max_connections 1024;
            }
        }
    }

    执行 推流命令播放视频

    ffmpeg -re -i ~/Desktop/XXXX.mov -c copy -f flv rtmp://localhost:1935/rtmplive/home

    执行 推流命令打开本地摄像头

    ffmpeg -f avfoundation -framerate 30 -video_size 1280x720 -i "0:0" -vcodec libx264 -preset ultrafast -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/rtmplive/home

     执行 播放

    ffplay rtmp://localhost:1935/rtmplive/home

     VLC File->OpenNetwork

    rtmp://localhost:1935/rtmplive/home

    nginx

    # nginx   // 启动
    # nginx -s stop   // 关闭
    # lsof -i:8080    // 查看端口占用
    

    error,  端口小于1024的需要root权限,要么提权,要么该端口

    nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
    
    he socket API bind() to a port less than 1024, such as 80 as your title mentioned, need root access.
    here is "Bind to ports less than 1024 without root access"
    and another easier way is to run nginx as root.
    

      

    参考:

    Android平台RTMP推流:https://www.jianshu.com/p/462e489b7ce0

    摄像头相关:https://blog.csdn.net/jeffasd/article/details/71205664

  • 相关阅读:
    C# TCP/IP 服务端 和 客户端
    (trigger)触发器的定义和作用
    AD账号登陆验证
    DES加密&解密字符串
    机器视觉(工业视觉)需要什么技能
    机器视觉对位贴合
    Halcon blob分析基本处理步骤
    cross_val_score 交叉验证与 K折交叉验证,嗯都是抄来的,自己作个参考
    50道SQL练习题及答案与详细分析(MySQL)
    MySQL8.0 ROW_NUMBER、RANK、DENSE_RANK窗口函数 分组排序排名
  • 原文地址:https://www.cnblogs.com/alanfang/p/8796634.html
Copyright © 2011-2022 走看看