Skip to content

v3_EN_SampleHttpFlvCluster

winlin edited this page Jan 6, 2022 · 27 revisions

HOME > EN > HTTP FLV Cluster

SRS HTTP FLV cluster deploy example

About the HTTP FLV cluster of SRS, read HTTP FLV

How to use multiple process for HTTP FLV? You can use HTTP reverse proxy, and SRS start the go-sharp project, which can proxy in load balance mode and detect the status of SRS. For go-sharp, read go-sharp

This example show how to deploy three SRS instance, listen at different port at a machine(user can deploy each to different machine, use same port), while one is origin server, another two are edge servers. We can publish RTMP to origin or edge, and play the RTMP/FLV at any edge. The latency is same to RTMP, 0.8-1s.

Suppose the server ip is 192.168.1.170

Step 1, get SRS. For detail, read GIT

git clone https://github.com/ossrs/srs
cd srs/trunk

Or update the exists code:

git pull

Step 2, build SRS. For detail, read Build

./configure && make

Step 3, config origin srs. For detail, read HTTP FLV

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

# conf/http.flv.live.conf
listen              1935;
max_connections     1000;
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
vhost __defaultVhost__ {
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
        hstrs       on;
    }
}

Step 4, config edge srs. For detail, read HTTP FLV

Save bellow as config, or use conf/http.flv.live.edge1.conf or conf/http.flv.live.edge2.conf:

# conf/http.flv.live.edge1.conf
listen              19351;
max_connections     1000;
pid                 objs/srs.flv.19351.pid;
srs_log_file        objs/srs.flv.19351.log;
http_server {
    enabled         on;
    listen          8081;
    dir             ./objs/nginx/html;
}
vhost __defaultVhost__ {
    mode remote;
    origin 127.0.0.1;
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
        hstrs       on;
    }
}

Step 5, start srs. For detail, read HTTP FLV

./objs/srs -c conf/http.flv.live.conf &
./objs/srs -c conf/http.flv.live.edge1.conf &
./objs/srs -c conf/http.flv.live.edge2.conf &

Step 6, start encoder. For detail, read read HTTP FLV

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 to publish:

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

The streams on SRS origin:

  • RTMP: rtmp://192.168.1.170/live/livestream
  • HTTP FLV: http://192.168.1.170:8080/live/livestream.flv

The streams on SRS edge1:

  • RTMP: rtmp://192.168.1.170:19351/live/livestream
  • HTTP FLV: http://192.168.1.170:8081/live/livestream.flv

The streams on SRS edge2:

  • RTMP: rtmp://192.168.1.170:19352/live/livestream
  • HTTP FLV: http://192.168.1.170:8082/live/livestream.flv

Step 7, play RTMP. For detail, read HTTP FLV

Origin 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: srs-player

Edge1 RTMP url is: rtmp://192.168.1.170:19351/live/livestream, User can use vlc to play the RTMP stream. Or, use online SRS player: srs-player-19351

Edge2 RTMP url is: rtmp://192.168.1.170:19352/live/livestream, User can use vlc to play the RTMP stream. Or, use online SRS player: srs-player-19352

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

Step 8, play HTTP FLV. For detail, read HTTP FLV

Origin HTTP FLV url: http://192.168.1.170:8080/live/livestream.flv, User can use vlc to play the HLS stream. Or, use online SRS player(you must input the flv url): jwplayer-flv

Edge1 HTTP FLV url: http://192.168.1.170:8081/live/livestream.flv, User can use vlc to play the HLS stream. Or, use online SRS player(you must input the flv url): jwplayer-flv-8081

Edge2 HTTP FLV url: http://192.168.1.170:8082/live/livestream.flv, User can use vlc to play the HLS stream. Or, use online SRS player(you must input the flv url): jwplayer-flv-8082

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

Winlin 2014.11

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