RTMP cluster deployment

1. Switch to the srs/trunk directory (the clone project has been completed in the virtual machine)

Refer to RTMP streaming, WebRTC streaming steps and problem solving

cd    srs/trunk

2. Write the SRS origin station configuration file
Save the following content as a file, such as conf/origin.conf, and specify this configuration file when the server starts (the conf folder of srs has this file).

vim conf/origin.conf #Enter this folder
i #Enter edit mode
Esc #Exit edit mode
: #Enter last line mode
wq #Save and exit vim

# conf/origin.conf

3. Write the SRS edge configuration file
Save the following content as a file, such as conf/edge.conf, and specify the configuration file when the server starts (the conf folder of srs has this file).
# conf/edge.conf


  4. Start SRS 

Turn off the virtual machine firewall before starting the server

Temporarily turn off the firewall command: systemctl stop firewalld

./objs/srs -c conf/origin.conf Enter to
start./objs/srs -c conf/edge.conf Enter to start

 5. Start the streaming encoder

Use the ffmpeg command to push the stream

 for((;;)); do \
        ./objs/ffmpeg/bin/ffmpeg -re -i ./doc/source.flv \
        -c copy \
        -f flv rtmp://10.1.4.159/live/livestream; \
        sleep 1; \
done

Node: ./objs/ffmpeg/bin/ is a relative path, you can remove ./objs/ffmpeg/bin/ for streaming

6. Watch RTMP stream

The RTMP stream address of the source station is: rtmp://10.1.4.111:19350/live/livestream, which can be viewed with VLC .
The edge RTMP stream address is: rtmp://10.1.4.111/live/livestream, you can use VLC to watch it .

Select WebRTC to pull streaming

After streaming is complete, open http://10.1.4.111:8080/players/rtc_player.html
to select the RTC player and click play (10.1.4.111 is the IP address in the virtual machine)
URL: webrtc://10.1.4.111/ live/livestream

 Questions:
1. Start ./objs/srs -c conf/origin.conf 
and enter ./etc/init.d/srs status        
to display Error: Process 1728 does not exist.
If you close the virtual machine firewall, then push ffmpeg and open VLC Pull rtmp://10.1.4.159:19350/live/livestream and play successfully (Origin)
If you enable the virtual machine firewall, then push ffmpeg, open VLC to pull rtmp://10.1.4.159:19350/live/livestream , the playback failed (Origin)
2. Cannot open the web page
For example, 10.1.4.159:8080, enter this URL, open it as blank, indicating that you need to configure 8080 service
Use the command: vim conf/origin.conf | vim conf/origin.conf to enter file, add the following content
http_server { enabled on; listen 8080; dir ./objs/nginx/html; }



3. WebRTC streaming
Open http://10.1.4.159:8080/players/rtc_player.html?schema=http URL to play, but cannot play.
Check on F12 of the current web page and find that
POST http://10.1.4.159:1985/rtc/v1/play/net::ERR_CONNECTION_REFUSED
is because port 1985 corresponds to the access port of http api, which is also the port for opening the console page. Configure the http_api service
    using the command: vim conf/origin.conf to enter the file, add the following content
            http_api {                 enabled on; #Open http——api service, the port number is 1985                 listen 1985;                 crossdomain on; #Open cross-domain request }     The same method configuration edge.conf file





 

Guess you like

Origin blog.csdn.net/Jiang5106/article/details/128716309