srs实现合流

简介: srs实现合流

文档:

https://ossrs.net/lts/zh-cn/docs/v5/doc/webrtc#room-to-live

合流需要打开配置文件的配置,主要是rtc

vhost __defaultVhost__ {
    http_hooks {
            enabled         on;
            on_publish      http://host.docker.internal:8001/im-signaling-service/srs_callback/on_publish;
            on_unpublish    http://host.docker.internal:8001/im-signaling-service/srs_callback/on_unPublish;
            on_play         http://host.docker.internal:8001/im-signaling-service/srs_callback/on_play;
            on_stop         http://host.docker.internal:8001/im-signaling-service/srs_callback/on_stop;
            on_dvr          http://host.docker.internal:8001/im-signaling-service/srs_callback/on_dvr;
            on_hls          http://host.docker.internal:8001/im-signaling-service/srs_callback/on_hls;
            on_hls_notify   http://host.docker.internal:8001/im-signaling-service/srs_callback/on_notify/[server_id]/[app]/[stream]/[ts_url][param];
    }
    rtc {
        enabled     on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
}

我们这里是多人合流,于是使用ffmpeg,此处71a8de7是房间号,1~10是设备标识

ffmpeg \
-i rtmp://192.168.1.114/71a8de7/1 \
-i rtmp://192.168.1.114/71a8de7/2 \
-i rtmp://192.168.1.114/71a8de7/3 \
-i rtmp://192.168.1.114/71a8de7/4 \
-i rtmp://192.168.1.114/71a8de7/5 \
-i rtmp://192.168.1.114/71a8de7/6 \
-i rtmp://192.168.1.114/71a8de7/7 \
-i rtmp://192.168.1.114/71a8de7/8 \
-i rtmp://192.168.1.114/71a8de7/9 \
-i rtmp://192.168.1.114/71a8de7/10 \
-vf "scale=854:480" -r 24 \
-filter_complex "
[0:v][1:v][2:v]hstack=inputs=3[Row1];
[3:v][4:v][5:v]hstack=inputs=3[Row2];
[6:v][7:v][8:v]hstack=inputs=3[Row3];
[9:v]scale=960:-1[Row4];
[Row1][Row2][Row3][Row4]vstack=inputs=4[Final]" \
-map "[Final]" \
-c:v h264_videotoolbox -profile:v high -b:v 1000k -q:v 23 \
-f flv rtmp://192.168.1.114/live/merge

然后播放


ffplay rtmp://192.168.1.114/live/merge

效果如下:

相关文章
|
6月前
|
Ubuntu
SRS RTMP流媒体服务器搭建
SRS RTMP流媒体服务器搭建
289 0
|
Web App开发 索引
流媒体服务器SRS部署
github地址:https://github.com/ossrs/srs 1,srs下载 http://ossrs.net/srs.release/releases/index.html 选择正式发形版 2,安装 # unzip SRS-CentOS6-x86_64-1.
4361 0
|
Web App开发 应用服务中间件 nginx
利用Simple-RTMP-Server(SRS)来进行直播
1、下载SRS 官方地址:http://www.ossrs.net/srs.release/releases/ 百度地址:http://pan.baidu.com/s/1kV8WQpx   2、编译安装SRS tar zxvf srs-2.0-b2.tar.gz cd srs-2.0-b2 mv trunk/ /usr/local/srs cd /usr/local/srs  ./configure --full     #--full,开启SRS所有的功能。
2818 0
|
6月前
|
NoSQL 容器 消息中间件
rtsp-simple-server + srs搭建流媒体服务器
rtsp-simple-server + srs搭建流媒体服务器
636 0
|
6月前
srs实现合流
srs实现合流
86 0
|
11月前
|
API
SRS SDP解析流程
SRS SDP解析流程
|
Web App开发 应用服务中间件 API
srs搭建rtmp流媒体服务器
srs搭建rtmp流媒体服务器
1097 0
srs搭建rtmp流媒体服务器
|
缓存 编解码 应用服务中间件
srs+rtmp和nginx+rtmp推流延时比较
srs+rtmp和nginx+rtmp推流延时比较
767 0
srs+rtmp和nginx+rtmp推流延时比较
|
编解码 网络协议 计算机视觉
ffmpeg推流rtmp指定udp传输
ffmpeg推流rtmp指定udp传输
613 0
|
网络协议 应用服务中间件 nginx
nginx 转发 rtmp 直播流
nginx 转发 rtmp 直播流
813 0