SRS streaming media service (1) SRS service construction and FFMPEG to realize analog live streaming push and pull

SRS (Simple Realtime Server) is a simple and efficient real-time video server that supports RTMP/WebRTC/HLS/HTTP-FLV/SRT/GB28181.

SRS can be expanded into a cluster, and it also involves multiple protocols and scenarios. The picture below is an overview map of SRS

SRS official wiki introduction

1. SRS service installation

Server environment: Linux (CentOS7)

Install SRS version: 4.0

It is recommended to download the stable version source code through the official website: SRS official website source code download address , and then start the installation from the fifth step

 The following is the Git method to pull the latest source code installation from the SRS official GitHub warehouse. The pulled code may be the latest development version source code

1. First install git through yum, CentOS7 does not come with git.

cd /usr/local //进入到/usr/local
mkdir git //创建git目录
cd git //进入git目录
yum -y install git //通过yum安装git

 2. Check the git version, because the yum version is not updated in time, here is an older version.

git --version

3. Enter the /usr/local directory, create the srs directory, and clone the SRS service to the srs directory through the git command.

cd /usr/local //进入/usr/local目录
mkdir srs //创建srs目录
ls //查看当前目录
cd srs  //进入刚创建的srs目录
git clone https://gitee.com/ossrs/srs.git  //将SRS克隆到本地

 4. Move srs to SRS4.0

mv srs SRS4.0

5. Compile SRS 

cd /usr/local/srs/SRS4.0/trunk/
./configure

make

 6. Start the SRS service and specify the startup configuration file

./objs/srs  -c  conf/srs.conf

Through the startup log prompt, you can see that you can view the running status command

./etc/init.d/srs status  //查看运行状态
./etc/init.d/srs stop    //停止运行

7. Visit http://192.168.5.102:8080

ifconfig //查看服务器IP

The firewall is enabled by default and no ports are opened

 Access failed

 

 Port 8080 and http are not enabled by default

 

Open port 8080, open http

firewall-cmd --zone=public --add-port=8080/tcp --permanent //永久开启8080端口
firewall-cmd --zone=public --add-service=http --permanent //永久开启http

 

 

 But it still can't be accessed now, because the verification discovery has not taken effect

firewall-cmd --zone=public --query-port=8080/tcp
firewall-cmd --zone=public --query-service=http  //验证是否生效

 Restart the firewall and verify again to take effect

 Visit http://192.168.5.102:8080 again successfully

2. Install FFMPEG tool

ffmpeg download address

 Find the ffmpeg tool bin directory path and add it to the system environment variable path

 Check the version, the installation is successful

 3. Use ffmpeg to simulate live streaming, and push the local video analog video stream to the SRS server. The default streaming port is 1935. Note that the open port number is 1935.

ffmpeg -re -i d://ffmpeg/ksxf.mp4  -c copy -f flv -y rtmp://192.168.5.102/live/livestream

 start streaming

Use ffplay to pull the stream

ffplay rtmp://192.168.5.102/live/livestream

Test the push and pull flow of SRS service successfully

If there is no sound in streaming, you may need to configure environment variables as follows:

Variable name: SDL_AUDIODRIVER

Variable value: directsound

Guess you like

Origin blog.csdn.net/weixin_44341110/article/details/120638140