Compile and run SRS on Ubuntu

Summary

This article describes how to build and run the SRS streaming server on an Ubuntu system, and how to experience its streaming and playback functions.

lab environment

操作系统版本:Ubuntu 22.04.3 LTS
gcc版本:11.4.0
g++版本:11.4.0

Dependent library installation

#安装必备开发工具链
sudo apt install -y build-essential automake cmake pkg-config tclsh 
#安装用于推流的ffmpeg程序
sudo apt install -y ffmpeg

Get SRS source code and build

After the development environment is installed, continue to enter the following commands:

#进入一个剩余磁盘空间足够的盘,准备clone srs源码仓库,例如用户的HOME目录:
cd ~

#克隆SRS源码仓库
git clone -b develop https://gitee.com/ossrs/srs.git

#进入SRS主干目录
cd srs/trunk

#检出v6.0.48版本,并创建自己的开发分支
git checkout v6.0.48
git switch -c dev-from-v6.0.48

#根据开发环境,编译依赖库,并生成makefile脚本
./configure

#开始编译SRS
make

Start the server

Enter the following command to start SRS:

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

Check if SRS starts successfully

You can open http://localhost:8080/ with a browser   , or execute the following command:

#查看SRS的状态
./etc/init.d/srs status
#或者看SRS的日志
tail -n 30 -f ./objs/srs.log

RTMP push test

Enter the following command in the terminal to test RTMP protocol streaming:

#SRS源码仓库的trunk目录的doc子目录下有测试用的source.flv影片。
ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://localhost/live/livestream

HTTP-FLV playback test

Paste the following URL in the address bar of the browser to perform the HTTP-FLV playback test:

http://localhost:8080/

Click the "SRS Player" link on the webpage, click the "SRS Player" label at the top of the webpage, and click the "Play Video" button on the page.

At this moment, if you see the video screen in the browser, it means that your SRS development environment on Windows has been successfully set up.

Going further, we can also test the lowest latency WebRTC function.

WebRTC push test

In the player web page opened in the previous step, perform the following operations:

1.点击网页顶部的“RTC推流”标签,在页面中点击“开始推流”按钮。
2.浏览器会提示你是否同意使用麦克风和摄像头,允许即可。

WebRTC playback test

Open a new browser instance, open the above player web page, and perform the following operations:

1.点击网页顶部的“RTC播放”标签,在页面中点击“播放视频”按钮。

At this moment, if you see the camera image in the browser, it means that you have successfully experienced the WebRTC streaming and playback function of SRS.

Stop the server

#输入如下命令可停止SRS
./etc/init.d/srs stop

#输入如下命令可再次启动SRS
./etc/init.d/srs start

Summarize

SRS streaming media server has excellent performance, extremely high stability and maintainability, which is due to its author's persistence in classic C++ programming ideas and in-depth application of the coroutine mechanism. Through the in-depth use of coroutine technology, the SRS project makes the readability and performance of the code outstanding among similar products. It is worthy of in-depth study by developers who love the classic C/C++ programming style.

Guess you like

Origin blog.csdn.net/bigwave2000/article/details/132286228