RTMP streaming media server construction
table of Contents
- Install srs streaming server
- Test srs streaming server
- Use OBS to push streaming
1. Install srs streaming media server (reference: RTMP distribution )
- srs官⽹:https://github.com/ossrs/srs
- The source code download speed of Code Cloud is fast: https://gitee.com/winlinvip/srs.oschina.git
- Download srs source code: git clone https://gitee.com/winlinvip/srs.oschina.git
- Enter the directory: cd srs.oschina/trunk
- Compile project (mac system): ./configure --osx && make
- Compilation success shows:
- Configure srs, set max_connections in srs.conf to 200 (max_connections too large for mac systems will cause problems): vim conf/srs.conf
- Configure srs and set max_connections in rtmp.conf to 200: vim conf/rtmp.conf
- Start srs: ./objs/srs -c conf/rtmp.conf
- Check whether the startup is successful through the log: tail -f ./objs/srs.log , or query the status to determine whether the startup is successful: ./etc/init.d/srs status
2. Test srs streaming media server
- Start the push stream encoder and use the FFMPEG command to push the stream: ffmpeg -re -i source.200kbps.768x320.flv -vcodec copy -acodec copy -f flv -y rtmp://192.168.16.39/live/livestream
- By default, the rtmp of srs uses the 1935 port. If the port is occupied or the port in srs.conf is modified, please adjust according to the situation; if the firewall is opened, check whether the 1935 port is allowed access.
- source.200kbps.768x320.flv: the flv video file to stream
- 192.168.16.39, the local ip, get the command: ifconfig| grep "inet"
- Watch RTMP stream
- ffmpeg拉流:ffplay rtmp://192.168.16.39/live/livestream
- Play with online SRS player: srs-player
- VCL watch, download address: https://www.videolan.org/
3. Use OBS to push streaming
- The command style of ffmpeg is not very friendly. It is recommended to use the mainstream OBS open source streaming software. The latest version can be downloaded from the official website https://obsproject.com/ . In the past, many network anchors used it for live streaming. The software supports local video files and camera push streaming.
1. File push
-
Add "media source"
-
Import play files, such as flv files
-
Enter the settings, enter the server and streaming secret key (same as srs push above)
-
After setting, click to start streaming
-
To pull the stream: ffplay rtmp://10.235.1.252/live/livestream
2. Camera push streaming
- It's almost the same as the previous one, the only difference is the addition of a "video capture device", which is not pretty...
- Modify the streaming key to what you want to set
- Start streaming
- To pull the stream: ffplay rtmp://10.235.1.252/live/livestream1
- More settings for OBS: https://cloud.tencent.com/document/product/267/32726