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

  • 相关阅读:
    隆重推出PowerDesinger 12.1.0.1913破解补丁
    Glowcode 6.0 破解手记,.Net IL技术
    爬虫如何抓取到Asp.Net中__doPostBack获取新页面的数据
    谁是股市上的最大受益者
    带强名的.net程序反向工程后汇编中的问题总结
    让所有的实体店成为网店的体验店
    推出网站大鱼搜索
    利用搜索引擎技术抢注域名
    在程序中显示PDF文件不依赖于Arcobat Reader的PDF阅读器开发
    用开源Carrot2的后缀树算法做Web文本聚类
  • 原文地址:https://www.cnblogs.com/alanfang/p/8796634.html
Copyright © 2011-2022 走看看