nginx hls测试

原创
08/23 14:48
阅读数 21

 

git clone https://github.com/arut/nginx-rtmp-module.git

下载nginx 解压进nginx源码

./configure --add-module=/path/to/nginx-rtmp-module
make
make install

nginx.conf

rtmp {
    server {
        listen 1935;
        chunk_size 4000;
        application live {
             live on;
             allow publish all;
             allow play all;
        }

        application hls {
            live on;
            hls on;
            hls_path /tmp/hls;
        }
    }
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {

        listen      8080;

        # This URL provides RTMP statistics in XML
        location /stat {
            rtmp_stat all;

            # Use this stylesheet to view XML as web page
            # in browser
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            # XML stylesheet to view RTMP stats.
            # Copy stat.xsl wherever you want
            # and put the full directory path here
            root /root/build/nginx-rtmp-module/;
        }

        location /hls {
            # Serve HLS fragments
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /tmp;
            add_header Cache-Control no-cache;
        }

        location /dash {
            # Serve DASH fragments
            root /tmp;
            add_header Cache-Control no-cache;
        }
    }

}

ffmpeg转发cctv的直播

 ffmpeg -i  http://cctvalih5ca.v.myalicdn.com/live/cctv1_2/index.m3u8 -acodec aac -vcodec libx264 -f flv rtmp://127.0.0.1/hls/test

VLC播放链接

http://127.0.0.1:8080/hls/test.m3u8

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部