1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/3rdparty/srs-bench/README.md

149 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# srs-bench
WebRTC benchmark on [pion/webrtc](https://github.com/pion/webrtc) for [SRS](https://github.com/ossrs/srs).
## Usage
编译和使用:
```bash
git clone https://github.com/ossrs/srs-bench.git && git checkout feature/rtc &&
make && ./objs/srs_bench -h
```
## Player for Live
直播播放压测,一个流,很多个播放。
首先推流到SRS
```bash
ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/live/livestream
```
然后启动压测比如100个
```bash
./objs/srs_bench -sr webrtc://localhost/live/livestream -nn 100
```
## Publisher for Live or RTC
直播或会议场景推流压测,一般会推多个流。
首先,推流依赖于录制的文件,请参考[DVR](#dvr)。
然后启动推流压测比如100个流
```bash
./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个流
```bash
./objs/srs_bench -pr webrtc://localhost/live/livestream_%d -sn 3 -sa a.ogg -sv v.h264 -fps 25
```
然后每个流都启动播放压测比如每个流2个播放
```bash
./objs/srs_bench -sr webrtc://localhost/live/livestream_%d -sn 3 -nn 2
```
> 备注:压测都是基于流,可以任意设计推流和播放的流路数,实现不同的场景。
> 备注URL的变量格式参考Go的`fmt.Sprintf`,比如可以用`webrtc://localhost/live/livestream_%03d`。
## DVR
录制场景,主要是把内容录制下来后,可分析,也可以用于推流。
首先推流到SRS参考[live](#player-for-live)。
```bash
ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/live/livestream
```
然后,启动录制:
```bash
./objs/srs_bench -sr webrtc://localhost/live/livestream -da a.ogg -dv v.h264
```
> 备注:录制下来的`a.ogg`和`v.h264`可以用做推流。
## RTC Plaintext
压测RTC明文播放
首先推流到SRS
```bash
ffmpeg -re -i doc/source.200kbps.768x320.flv -c copy -f flv -y rtmp://localhost/live/livestream
```
然后启动压测指定是明文非加密比如100个
```bash
./objs/srs_bench -sr webrtc://localhost/live/livestream?encrypt=false -nn 100
```
> Note: 可以传递更多参数详细参考SRS支持的参数。
## Regression Test
回归测试需要先启动[SRS](https://github.com/ossrs/srs/issues/307)支持WebRTC推拉流
```bash
eip=$(ifconfig en0 inet| grep 'inet '|awk '{print $2}')
if [[ ! -z $eip ]]; then
docker run -p 1935:1935 -p 8080:8080 -p 1985:1985 -p 8000:8000/udp \
--rm --env CANDIDATE=$(ifconfig en0 inet| grep 'inet '|awk '{print $2}')\
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:v4.0.76 objs/srs -c conf/rtc.conf
fi
```
然后运行回归测试用例,如果只跑一次,可以直接运行:
```bash
go test ./srs -mod=vendor -v
```
也可以用make编译出重复使用的二进制
```bash
make test && ./objs/srs_test -test.v
```
可以给回归测试传参数,这样可以测试不同的序列,比如:
```bash
go test ./srs -mod=vendor -v -srs-server=127.0.0.1
# Or
make test && ./objs/srs_test -test.v -srs-server=127.0.0.1
```
支持的参数如下:
* `-srs-server`RTC服务器地址。默认值`127.0.0.1`
* `-srs-stream`RTC流地址。默认值`/rtc/regression`
* `-srs-log`,是否开启详细日志。默认值:`false`
* `-srs-timeout`每个Case的超时时间毫秒。默认值`3000`即3秒。
* `-srs-play-pli`播放时PLI的间隔毫秒。默认值`5000`即5秒。
* `-srs-play-ok-packets`,播放时,收到多少个包认为是测试通过,默认值:`10`
* `-srs-publish-audio`,推流时,使用的音频文件。默认值:`avatar.ogg`
* `-srs-publish-video`,推流时,使用的视频文件。默认值:`avatar.h264`
* `-srs-publish-video-fps`推流时视频文件的FPS。默认值`25`
其他不常用参数:
* `-srs-https`是否连接HTTPS-API。默认值`false`即连接HTTP-API。
2021.01, Winlin