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

  • 相关阅读:
    memcached 服务器安装
    农行接口开发
    mysql备份
    IIS下的FTP使用
    建行接口
    Android网络编程之一个Android下菜单系统模块的实现(客户端—更新菜单)
    Android网络编程之一个Android下菜单系统模块的实现(客户端—更新桌号)
    Android网络编程之下菜单系统中的真机调试问题小结
    Android网络编程之一个Android下菜单系统模块的实现(服务器端—更新桌号)
    Android之一个简单的Activity启动画面
  • 原文地址:https://www.cnblogs.com/alanfang/p/8796634.html
Copyright © 2011-2022 走看看