您的位置:首页 > 其它

mac os上搭建最简单rtmp直播服务器

2017-07-05 16:40 218 查看
. 下载

nginx , nginx-rtmp (https://github.com/arut/nginx-rtmp-module), openssl

先编译openssl :  ./Configure darwin64-x86_64-cc -shared ,直接./config 会只编译32位版本。导致后面编译无法进行

  编译nginx  ./configure --prefix=/usr/local  --with-module=<nginx-rtmp path>;   sudo make install

install后nginx在/usr/local/sbin中

. 编辑

/usr/local/conf/nginx.conf,server配置块中加入:

location /hls {

        # Serve HLS fragments

        types {

        application/vnd.apple.mpegurl m3u8;

        video/mp2t ts; 

        }   

        root /tmp;

        add_header Cache-Control no-cache;

    }   
将 /hls 路径url 使用 hlv 协议。视频存放根目录/tmp
最后再加入rtmp协议支持(http配置块外面),推流用:

    rtmp {

     server {

            listen 1935;

            application hls {

                allow play all;

                live on;

                hls on;

                hls_path /tmp/hls;

            }

      }

然后启动nginx

推流

 准备一个mp4文件,使用ffmpeg 命令推流:

ffmpeg -re -i /tmp/test.mp4 -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 rtmp://localhost/hls/movie

拉流

vlc中打开网络流:

hlv方式:http://127.0.0.1:8090/hls/movie.m3u8

rtmp方式:rtmp://127.0.0.1/hls/movie

参阅
http://www.tuicool.com/articles/iauQNr
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  图形图像 直播