Skip to content

v1_EN_SampleHTTP

winlin edited this page Nov 17, 2014 · 36 revisions

SRS HTTP server deploy example

SRS embeded HTTP server, to delivery HLS and files.

Note: Never use SRS HTTP server for online service.

Suppose the server ip is 192.168.1.170

Step 1, get SRS. For detail, read GIT

git clone https://github.com/winlinvip/simple-rtmp-server
cd simple-rtmp-server/trunk

Or update the exists code:

git pull

Step 2, build SRS. For detail, read Build

./configure --disable-all --with-hls --with-ssl --with-http-server && make

Step 3, config srs. For detail, read HLSHTTP服务器

Save bellow as config, or use conf/http.hls.conf:

# conf/http.hls.conf
listen              1935;
max_connections     1000;
http_stream {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
vhost __defaultVhost__ {
    hls {
        enabled         on;
        hls_path        ./objs/nginx/html;
        hls_fragment    10;
        hls_window      60;
    }
}

Note: The hls_path must exists, srs never create it. For detail, read HLS

第四步,启动SRS。 For detail, read HLSHTTP服务器

./objs/srs -c conf/http.hls.conf

备注:请确定srs-http-server已经启动,可以访问http://192.168.1.170:8080/nginx.html,若能看到nginx is ok则没有问题。

备注:实际上提供服务的是SRS,可以看到响应头是Server: SRS/0.9.51之类。

第五步,启动推流编码器。 For detail, read HLS

Use FFMPEG to publish stream:

    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

Or use FMLE(which support h.264+aac) to publish, read Transcode2HLS

FMS URL: rtmp://192.168.1.170/live
Stream: livestream

生成的流地址为:

  • RTMP流地址为:rtmp://192.168.1.170/live/livestream
  • HLS流地址为: http://192.168.1.170:8080/live/livestream.m3u8

第流步,观看RTMP流。 For detail, read HLS

RTMP url is: rtmp://192.168.1.170:1935/live/livestream

User can use vlc to play the RTMP stream.

Or, use online SRS player: http://winlinvip.github.io/srs.release/trunk/research/players/srs_player.html?vhost=defaultVhost&autostart=true&server=192.168.1.170&app=live&stream=livestream&port=1935

Note: Please replace all ip 192.168.1.170 to your server ip.

第七步,观看HLS流。 For detail, read HLS

HLS流地址为: http://192.168.1.170:8080/live/livestream.m3u8

可以使用VLC观看。

或者使用在线SRS播放器播放:http://winlinvip.github.io/srs.release/trunk/research/players/jwplayer6.html?vhost=defaultVhost&hls_autostart=true&server=192.168.1.170&app=live&stream=livestream&hls_port=8080

Note: Please replace all ip 192.168.1.170 to your server ip.

注意:VLC无法观看纯音频流,jwplayer可以观看。

分发纯音频流参考:HLS audio only

Q&A

RTMP流能看,HLS看不了

  • 确认srs-http-server启动并且可以访问:nginx is ok页面能访问。
  • 确认m3u8文件能下载:浏览器打开http://192.168.1.170:8080/live/livestream.m3u8,ip地址换成你服务器的IP地址。
  • 若m3u8能下载,可能是jwplayer的问题,使用vlc播放地址:http://192.168.1.170:8080/live/livestream.m3u8,ip地址换成你服务器的IP地址。
  • 若VLC不能播放,将m3u8下载后,用文本编辑器打开,将m3u8文件内容发到QQ群中,或者贴到issue中。寻求帮助。
  • 还有可能是编码问题,参考下面的“RTMP流和HLS流内容不一致”

RTMP流内容和HLS流内容不一致

  • 一般这种问题出现在使用上面的例子推流,然后换成别的编码器推流,或者换个文件推流。
  • 可能是流的编码不对(推流时使用FMLE),HLS需要h.264+aac,需要转码,参考只转码音频Transcode2HLS或者全转码HLS+Transcode

Winlin 2014.4

Welcome to SRS wiki!

SRS 5.0 wiki

Please select your language:

SRS 4.0 wiki

Please select your language:

SRS 3.0 wiki

Please select your language:

SRS 2.0 wiki

Please select your language:

SRS 1.0 wiki

Please select your language:

Clone this wiki locally