srs2.0测试hls

来源:互联网 发布:mac看不到备份文件 编辑:程序博客网 时间:2024/06/07 22:29
2.0  测试
一:下载
先下载源码,地址:https://github.com/ossrs/srs/tree/2.0release
二:不转码点播
1 编译

./configure --disable-all --with-ssl --with-hls --with-nginx && make

2 配置
vhost __defaultVhost__ {

   hls {
        enabled         off;  # 是否开启hls,不转码切hls。
        hls_fragment    2;   # 指定ts切片的最小长度,单位秒
        hls_window      10;  # 指定HLS窗口大小,即m3u8中ts文件的时长之和;单位秒
        hls_path        /data/channellist; # 直播推流存放住目录
        hls_m3u8_file   channel[stream]/700.m3u8; # m3u8索引文件存放路径;码率可以设置,但ts和m3u8的名称必须保持一致,
        hls_ts_file     channel[stream]/700/[year][month][day]/[2006][01][02][T][15][04][05].ts;  # 直播ts文件存放路径
    }

 transcode {
        enabled     on;
         ffmpeg      /usr/local/ffmpeg/bin/ffmpeg;


        engine ff1 {
            enabled         on;
            vcodec          libx264;
              vparams {
                 r 25;
                g 25;
                keyint_min 25;
                sc_threshold 0;
            }
            acodec          copy;
            oformat         hls;
            
             output          /usr/local/nginxtmp/html/otv/[stream].m3u8; 

              #强制转码hls
            #   output          rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]1;  
        }

        engine ff {
            enabled         on;
            vcodec          libx264;
              vparams {
                 r 25;
                g 25;
                keyint_min 25;
                sc_threshold 0;
            }


            acodec          copy;
            #oformat         hls;
            
          #   output          /usr/local/nginxtmp/html/otv/[stream].m3u8;

           #强制转码rtmp

            output          rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]1;  
        }
     }
}

3 启动
./objs/srs -c conf/hls.conf
4 推流
for((;;)); do \
        ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
        -vcodec copy -acodec copy \
        -f flv -y rtmp://192.168.1.170/live/livestream; \
        sleep 1; \
    done

或第三方软件推流,如obs。

或ffmpeg -re -i cw_1h.ts  -vcodec  copy  -acodec aac -bsf:a aac_adtstoasc  -f flv -y rtmp://10.80.3.17:1935/APP/19

5 点播
生成的流地址为:
    RTMP流地址为:rtmp://192.168.1.170/app/通道
    HLS流地址为: http://192.168.1.170/app/xx.m3u8(需要配置nginx)
三:转码点播
1 编译
./configure --with-nginx --with-ffmpeg --with-transcode && make
编译后的特性为:
features: --prefix=/usr/local/srs --with-hls --with-hds --with-dvr --without-nginx --with-ssl --with-ffmpeg --with-transcode --with-ingest --with-stat --with-http-callback --with-http-server --without-stream-caster --with-http-api --

with-librtmp --without-research --with-utest --without-gperf --without-gmc --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace
2 启动
./objs/srs -c conf/transcode2hls.audio.only.conf
3 推流
  for((;;)); do \
        ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.200kbps.768x320.flv \
        -vcodec copy -acodec copy \
        -f flv -y rtmp://192.168.1.170/live/livestream; \
        sleep 1; \
    done
或第三方软件推流,如obs。
4 点播
    RTMP流地址为(FMLE推流无HLS地址):rtmp://192.168.1.170/live/livestream
    转码后的RTMP流地址为:rtmp://192.168.1.170/live/livestream_ff
    转码后的HLS流地址为: http://192.168.1.170/live/livestream_ff.m3u8

1 0
原创粉丝点击