• Stars
    star
    397
  • Rank 108,561 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SB(SRS Bench) is a set of benchmark and regression test tools, for SRS and other media servers, supports HTTP-FLV, RTMP, HLS, WebRTC and GB28181.

srs-bench

SB(SRS Bench) is a set of benchmark and regression test tools, for SRS and other media servers, supports HTTP-FLV, RTMP, HLS, WebRTC and GB28181.

For RTMP/HLS/FLV benchmark, please use branch master.

Usage

下载代码和编译:

git clone -b feature/rtc https://github.com/ossrs/srs-bench.git && 
cd srs-bench && make

编译会生成下面的工具:

  • ./objs/srs_bench 压测,模拟大量客户端的负载测试,支持SRS、GB28181和Janus三种场景。
  • ./objs/srs_test 回归测试(SRS),SRS服务器的回归测试。
  • ./objs/srs_gb28181_test 回归测试(GB28181),GB服务器的回归测试。
  • ./objs/srs_blackbox_test 黑盒测试(SRS),SRS服务器的黑盒测试,也可以换成其他媒体服务器。

Note: 查看工具的全部参数请执行./objs/xx -h

有些场景,若需要编译和启动SRS:

git clone https://github.com/ossrs/srs.git &&
cd srs/trunk && ./configure --h265=on --gb28181=on && make &&
./objs/srs -c conf/console.conf

具体场景,请按下面的操作启动测试。

Player for Live

直播播放压测,一个流,很多个播放。

首先,推流到SRS:

ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/live/livestream

然后,启动压测,比如100个:

./objs/srs_bench -sr webrtc://localhost/live/livestream -nn 100

Publisher for Live or RTC

直播或会议场景推流压测,一般会推多个流。

首先,推流依赖于录制的文件,请参考DVR

然后,启动推流压测,比如100个流:

./objs/srs_bench -pr webrtc://localhost/live/livestream_%d -sn 100 -sa a.ogg -sv v.h264 -fps 25

注意:帧率是原始视频的帧率,由于264中没有这个信息所以需要传递。

Multipel Player or Publisher for RTC

会议场景的播放压测,会多个客户端播放多个流,比如3人会议,那么就有3个推流,每个流有2个播放。

首先,启动推流压测,比如3个流:

./objs/srs_bench -pr webrtc://localhost/live/livestream_%d -sn 3 -sa a.ogg -sv v.h264 -fps 25

然后,每个流都启动播放压测,比如每个流2个播放:

./objs/srs_bench -sr webrtc://localhost/live/livestream_%d -sn 3 -nn 2

备注:压测都是基于流,可以任意设计推流和播放的流路数,实现不同的场景。

备注:URL的变量格式参考Go的fmt.Sprintf,比如可以用webrtc://localhost/live/livestream_%03d

DVR for Benchmark

录制场景,主要是把内容录制下来后,可分析,也可以用于推流。

首先,推流到SRS,参考live

ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/live/livestream

然后,启动录制:

./objs/srs_bench -sr webrtc://localhost/live/livestream -da a.ogg -dv v.h264

备注:录制下来的a.oggv.h264可以用做推流。

RTC Plaintext

压测RTC明文播放:

首先,推流到SRS:

ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/live/livestream

然后,启动压测,指定是明文(非加密),比如100个:

./objs/srs_bench -sr webrtc://localhost/live/livestream?encrypt=false -nn 100

Note: 可以传递更多参数,详细参考SRS支持的参数。

Regression Test

回归测试需要先启动SRS,支持WebRTC推拉流:

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

然后运行回归测试用例,如果只跑一次,可以直接运行:

go test ./srs -mod=vendor -v -count=1

也可以用make编译出重复使用的二进制:

make && ./objs/srs_test -test.v

Note: 注意由于pion不支持DTLS 1.0,所以SFU必须要支持DTLS 1.2才行。

运行结果如下:

$ make && ./objs/srs_test -test.v
=== RUN   TestRTCServerVersion
--- PASS: TestRTCServerVersion (0.00s)
=== RUN   TestRTCServerPublishPlay
--- PASS: TestRTCServerPublishPlay (1.28s)
PASS

可以给回归测试传参数,这样可以测试不同的序列,比如:

go test ./srs -mod=vendor -v -count=1 -srs-server=127.0.0.1
# Or
make && ./objs/srs_test -test.v -srs-server=127.0.0.1

可以只运行某个用例,并打印详细日志,比如:

make && ./objs/srs_test -test.v -srs-log -test.run TestRtcBasic_PublishPlay

支持的参数如下:

  • -srs-server,RTC服务器地址。默认值:127.0.0.1
  • -srs-stream,RTC流地址,一般会加上随机的后缀。默认值:/rtc/regression
  • -srs-timeout,每个Case的超时时间,毫秒。默认值:5000,即5秒。
  • -srs-publish-audio,推流时,使用的音频文件。默认值:avatar.ogg
  • -srs-publish-video,推流时,使用的视频文件。默认值:avatar.h264
  • -srs-publish-video-fps,推流时,视频文件的FPS。默认值:25
  • -srs-vnet-client-ip,设置pion/vnet客户端的虚拟IP,不能和服务器IP冲突。默认值:192.168.168.168

其他不常用参数:

  • -srs-log,是否开启详细日志。默认值:false
  • -srs-play-ok-packets,播放时,收到多少个包认为是测试通过,默认值:10
  • -srs-publish-ok-packets,推流时,发送多少个包认为时测试通过,默认值:10
  • -srs-https,是否连接HTTPS-API。默认值:false,即连接HTTP-API。
  • -srs-play-pli,播放时,PLI的间隔,毫秒。默认值:5000,即5秒。
  • -srs-dtls-drop-packets,DTLS丢包测试,丢了多少个包算成功,默认值:5

Note: 查看全部参数请执行./objs/srs_test -h

GB28181 Test

支持GB28181的压测,使用选项-sfu gb28181可以查看帮助:

make && ./objs/srs_bench -sfu gb28181 --help

运行回归测试用例,更多命令请参考Regression Test

go test ./gb28181 -mod=vendor -v -count=1

也可以用make编译出重复使用的二进制:

make && ./objs/srs_gb28181_test -test.v

支持的参数如下:

  • -srs-sip,SIP服务器地址。默认值:tcp://127.0.0.1:5060
  • -srs-stream,GB的user,即流名称,一般会加上随机的后缀。默认值:3402000000
  • -srs-timeout,每个Case的超时时间,毫秒。默认值:11000,即11秒。
  • -srs-publish-audio,推流时,使用的音频文件。默认值:avatar.aac
  • -srs-publish-video,推流时,使用的视频文件。默认值:avatar.h264
  • -srs-publish-video-fps,推流时,视频文件的FPS。默认值:25

其他不常用参数:

  • -srs-log,是否开启详细日志。默认值:false

Note: 查看全部参数请执行./objs/srs_gb28181_test -h

Blackbox Test

使用FFmpeg作为客户端,对流媒体服务器SRS进行黑盒压测,完全黑盒的回归测试。

运行回归测试用例,如果只跑一次,可以直接运行:

go test ./blackbox -mod=vendor -v -count=1

也可以用make编译出重复使用的二进制:

make && ./objs/srs_blackbox_test -test.v

由于黑盒测试依赖特殊的FFmpeg,可以在Docker中编译和启动:

docker run --rm -it -v $(pwd):/g -w /g ossrs/srs:ubuntu20 bash
make && ./objs/srs_blackbox_test -test.v

Note: 依赖SRS二进制,当然也可以在这个Docker中编译SRS,具体请参考SRS的Wiki。

支持的参数如下:

  • -srs-binary,每个测试用例都需要启动一个SRS服务,因此需要设置SRS的位置。默认值:../../objs/srs
  • -srs-ffmpeg,FFmpeg工具的位置,用来推流和录制。默认值:ffmpeg
  • -srs-ffprobe,ffprobe工具的位置,用来分析流的信息。默认值:ffprobe
  • -srs-timeout,每个Case的超时时间,毫秒。默认值:64000,即64秒。
  • -srs-publish-avatar,测试源文件路径。默认值:avatar.flv
  • -srs-ffprobe-duration,每个Case的探测时间,毫秒。默认值:16000,即16秒。
  • -srs-ffprobe-timeout,每个Case的探测超时时间,毫秒。默认值:21000,即21秒。

其他不常用参数:

  • -srs-log,是否开启详细日志。默认值:false
  • -srs-stdout,是否开启SRS的stdout详细日志。默认值:false
  • -srs-ffmpeg-stderr,是否开启FFmpeg的stderr详细日志。默认值:false
  • -srs-dvr-stderr,是否开启DVR的stderr详细日志。默认值:false
  • -srs-ffprobe-stdout,是否开启FFprobe的stdout详细日志。默认值:false

由于每个黑盒的用例时间都很长,可以开启并行:

./objs/srs_blackbox_test -test.v -test.parallel 8

Note: 查看全部参数请执行./objs/srs_blackbox_test -h

GCOVR

本机生成覆盖率时,我们使用工具gcovr

在macOS上安装gcovr:

pip3 install gcovr

在CentOS上安装gcovr:

yum install -y python2-pip &&
pip install lxml && pip install gcovr

Janus

支持Janus的压测,使用选项-sfu janus可以查看帮助:

make && ./objs/srs_bench -sfu janus --help

首先需要启动Janus,推荐使用janus-docker:

ip=$(ifconfig en0 inet|grep inet|awk '{print $2}') &&
sed -i '' "s/nat_1_1_mapping.*/nat_1_1_mapping=\"$ip\"/g" janus.jcfg &&
docker run --rm -it -p 8080:8080 -p 8443:8443 -p 20000-20010:20000-20010/udp \
    -v $(pwd)/janus.jcfg:/usr/local/etc/janus/janus.jcfg \
    -v $(pwd)/janus.plugin.videoroom.jcfg:/usr/local/etc/janus/janus.plugin.videoroom.jcfg \
    registry.cn-hangzhou.aliyuncs.com/ossrs/janus:v1.0.7

若启动成功,打开页面,可以自动入会:http://localhost:8080

模拟5个推流入会,可以在页面看到入会的流:

make -j10 && ./objs/srs_bench -sfu janus \
  -pr webrtc://localhost:8080/2345/livestream \
  -sa avatar.ogg -sv avatar.h264 -fps 25 -sn 5

模拟5个拉流入会,只拉流不推流:

make -j10 && ./objs/srs_bench -sfu janus \
  -sr webrtc://localhost:8080/2345/livestream \
  -nn 5

2021.01, Winlin

More Repositories

1

srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
C++
25,633
star
2

state-threads

Lightweight thread library for C/C++ coroutine (similar to goroutine), for high performance network servers.
C++
720
star
3

httpx-static

A HTTP/HTTPS API proxy for SRS.
Go
643
star
4

oryx

Oryx(SRS Stack) is an all-in-one, out-of-the-box, and open-source video solution for creating online video services, including live streaming and WebRTC, on the cloud or through self-hosting.
JavaScript
537
star
5

flutter_live

Live streaming player, iOS+Android, RTMP/HTTP-FLV/HLS/WebRTC, by Flutter+SRS.
JavaScript
332
star
6

srs-sea

The SEA(Stream Encoder for Android) publish live stream to SRS over HTTP-FLV.
313
star
7

srs-librtmp

The client library srs-librtmp of SRS(https://github.com/ossrs/srs)
249
star
8

librtmp

Fork from http://git.ffmpeg.org/rtmpdump integrated with srs.
C
142
star
9

go-oryx-lib

The public multiple media library for https://github.com/ossrs/oryx.
Go
107
star
10

srs-console

SRS console at http://ossrs.net/console
93
star
11

srs-gb28181

GB28181 server based on SRS
83
star
12

dev-docker

The docker for development environment for SRS.
Dockerfile
77
star
13

srs-unity

WebRTC Samples with SRS SFU server for Unity.
C#
72
star
14

signaling

A demo WebRTC signaling for https://github.com/ossrs/srs
JavaScript
49
star
15

ai-talk

AI-Talk allows you to talk with OpenAI GPT.
Go
34
star
16

srs-sip

The SIP demo application for SRS GB28181.
JavaScript
31
star
17

srs-ble

The BLE is a better BULL LIVE ENCODER than OBS for PC(Windows/MAC).
31
star
18

srs-dolphin

Multiple cores ability for https://github.com/ossrs/srs
26
star
19

Typecho-Plugin-SrsPlayer

SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc.
JavaScript
20
star
20

go-sharp

The go-sharp(go-srs-http-advanced-reverse-proxy) is the proxy for SRS HTTP FLV.
19
star
21

srs-k2

Apply https://github.com/k2-fsa/sherpa-ncnn in live streaming and WebRTC
Go
18
star
22

ai-translation

AI translation for English study based on FFmpeg, Whisper, Fairseq, OBS, SRS, and GPT.
Python
17
star
23

srs-k8s-template

Template repository for deploying SRS to any K8s service by GitHub Actions
16
star
24

WordPress-Plugin-SrsPlayer

SRS Player is a video streaming player, supports HLS/HTTP-FLV/WebRTC etc.
JavaScript
14
star
25

tc-ui

WebUI for tcconfig and tc on Linux server.
JavaScript
13
star
26

srs-windows

Adapt SRS for Windows
C++
12
star
27

srs-docs

The documents for SRS
JavaScript
11
star
28

srs-helm

Helm Charts for SRS media server and Oryx media solution.
Shell
10
star
29

issues-translation

Use AI/GPT to translate GitHub issues into English.
Python
5
star
30

flutter_rtc

WebRTC demo by Flutter for https://github.com/ossrs/srs
Dart
4
star
31

srs-simulcast

WebRTC simulcast for SRS
C++
4
star
32

srs-spa

The SPA(Stream Player for Android) play live stream from SRS over HTTP-FLV.
4
star
33

srs-ack-template

Template repository for deploying SRS to ACK(Alibaba Cloud Container Service for Kubernetes)
4
star
34

tea

TEA(TC eBPF for AV) is a network emulator and a set of tools for SRS and any media systems.
C
4
star
35

srs-las

LAS server based on SRS
C++
3
star
36

flutter_srs

A new Flutter project.
C++
2
star
37

srs-sctp

WebRTC datachannel for SRS
C++
2
star
38

srs-aks-template

Template repository for deploying SRS to AKS(Azure Kubernetes Service)
2
star
39

srs-toolkit-idea

SRS Toolkit for IntelliJ IDEA - a plugin for integrating with SRS from JetBrains IDEs, for https://github.com/ossrs/srs
Kotlin
2
star
40

ossrs.net

For https://ossrs.net
HTML
1
star
41

srs-droplet-template

Deploy SRS to DigitalOcean droplet
1
star
42

srs-g711

Support G.711 for SRS
C++
1
star
43

srs-secure-api

Demonstrated Secure HTTP API for SRS.
1
star
44

k8s-set-context-action

GitHub Action for setting context before deploying to Kubernetes clusters
JavaScript
1
star