ossrs / srs-gb28181

GB28181 server based on SRS
https://ossrs.net
MIT License
83 stars 41 forks source link

国标流推到srs使用webrtc播放问题 #40

Open RaymanTao opened 2 years ago

RaymanTao commented 2 years ago

注意:提问前,请先看FAQ(Please read FAQ before file an issue) https://github.com/ossrs/srs/issues/2716

描述(Description)

描述你遇到了什么问题(Please description your issue here) gb28181推流webrtc无法播放,但rtmp播放没有问题

  1. SRS版本(Version): xxxxxx feature/gb28181 最新版本
  2. SRS的日志如下(Log):
    
    ![1642496866(1)](https://user-images.githubusercontent.com/23013326/149905681-202a8d93-ce86-4c56-b4d6-a6768bd8028e.png)

xxxxxxxxxxxx


1. SRS的配置如下(Config):

push gb28181 stream to SRS.

listen 1935; max_connections 1000; daemon off; srs_log_tank console;

http_api { enabled on; listen 1985; }

http_server { enabled on; listen 8080; }

stats { network 0; }

stream_caster { enabled on; caster gb28181;

# 转发流到rtmp服务器地址与端口
# TODO: https://github.com/ossrs/srs/pull/1679/files#r400875104
# [stream] is VideoChannelCodecID(视频通道编码ID) for sip
# 自动创建的道通[stream] 是‘chid[ssrc]’ [ssrc]是rtp的ssrc
# [ssrc] rtp中的ssrc
output              rtmp://127.0.0.1:1935/live/[stream];

# 接收设备端rtp流的多路复用端口
listen              9000;
# 多路复用端口类型,on为tcp,off为udp
# 默认:on
tcp_enable            on;

# rtp接收监听端口范围,最小值
rtp_port_min        58200;
# rtp接收监听端口范围,最大值
rtp_port_max        58300;

# 是否等待关键帧之后,再转发,
# off:不需等待,直接转发
# on:等第一个关键帧后,再转发
wait_keyframe       on;

# rtp包空闲等待时间,如果指定时间没有收到任何包
# rtp监听连接自动停止,发送BYE命令
rtp_idle_timeout    30;

# 是否转发音频流
# 目前只支持aac格式,所以需要设备支持aac格式
# on:转发音频
# off:不转发音频,只有视频
# *注意*!!!:flv 只支持11025  22050  44100 三种
# 如果设备端没有三种中任何一个,转发时为自动选择一种格式
# 同时也会将adts的头封装在flv aac raw数据中
# 这样的话播放器为自动通过adts头自动选择采样频率
# 像ffplay, vlc都可以,但是flash是没有声音,
# 因为flash,只支持11025 22050 44100
audio_enable        off;

# 服务器主机号,可以域名或ip地址
# 也就是设备端将媒体发送的地址,如果是服务器是内外网
# 需要写外网地址,
# 调用api创建stream session时返回ip地址也是host
# $CANDIDATE 是系统环境变量,从环境变量获取地址,如果没有配置,用*
# *代表指定stats network 的网卡号地址,如果没有配置network,默认则是第0号网卡地址
# TODO: https://github.com/ossrs/srs/pull/1679/files#r400917594
#host       $CANDIDATE;
host    192.168.1.115;

#根据收到ps rtp包自带创建rtmp媒体通道,不需要api接口创建
#rtmp地址参数[stream] 就是通道id  格式chid[ssrc]
auto_create_channel   off;

sip {
    # 是否启用srs内部sip信令
    # 为on信令走srs, off 只转发ps流
    enabled on;

    # sip监听udp端口
    listen              5060;

    # SIP server ID(SIP服务器ID).
    # 设备端配置编号需要与该值一致,否则无法注册
    serial              34020000002000000001;

    # SIP server domain(SIP服务器域)
    realm               3402000000;

    # 服务端发送ack后,接收回应的超时时间,单位为秒
    # 如果指定时间没有回应,认为失败
    ack_timeout         30;

    # 设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳
    # 认为设备离线
    keepalive_timeout   120;

    # 注册之后是否自动给设备端发送invite
    # on: 是  off 不是,需要通过api控制
    auto_play           on;
    # 设备将流发送的端口,是否固定
    # on 发送流到多路复用端口 如9000
    # off 自动从rtp_mix_port - rtp_max_port 之间的值中
    # 选一个可以用的端口
    invite_port_fixed     on;

    # 向设备或下级域查询设备列表的间隔,单位(秒)
    # 默认60秒
    query_catalog_interval  60;
}

}

rtc_server { enabled on;

# Listen at udp://8000
listen          8000;
#
# The $CANDIDATE means fetch from env, if not configed, use * as default.
#
# The * means retrieving server IP automatically, from all network interfaces,
# @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124
#candidate       $CANDIDATE;
candidate        192.168.1.115;

}

vhost defaultVhost { rtc { enabled on; rtmp_to_rtc on; bframe discard; }

http_remux {
    enabled     on;
    mount       [vhost]/[app]/[stream].flv;
}

} xxxxxxxxxxxx



**重现(Replay)**

> 重现Bug的步骤(How to replay bug?)

1. 国标设备注册服务器自动推流
2. ffmplay播放rtmp没有问题
3. http://ip:8080/players/rtc_player.html 无法播放视频
4. ![1642497110(1)](https://user-images.githubusercontent.com/23013326/149906365-987b3f09-e3e7-49b9-8109-9e2dba17d4b4.png)

**期望行为(Expect)**
webrtc可以正常播放国标流
> 描述你期望发生的事情(Please describe your expectation)
xiaojiege123 commented 2 years ago

我也遇到了同样的问题,测试后发现调用api回调,计数都没有问题,rtmp播放也没有问题,就rtc播放失败,期待大佬们抓紧解决。

juicechu commented 2 years ago

Webrtc 是不是不支持 H265,我看srs_app_rtc_conn 里面没有对 H265 sdp 的封装和实现

liangyun1979 commented 2 years ago

我也遇见同样的问题,用其他版本配置rtc.conf,然后通过ffmpeg推流到srs上,可以成功播放webrtc,但采用gb28181分支版本,播放hls直播流没问题,但webrtc就不行,望大佬解决支持

tepower commented 2 years ago

之前用GB+RTC,延迟能控制毫秒级,基本指哪打哪,现在延迟大概1S左右,真不知道如何优化了。🤣

KindHeartedTraveler commented 2 years ago

你看下RTC播放器页面的URL,结尾是不是带了.flv,去掉就可以播放了

tepower commented 2 years ago

没有带.flv,我是直接用SRS的GB28181播放器放的。 image

Topdear commented 2 years ago

我也遇到同样问题,求解

Topdear commented 1 year ago

你看下RTC播放器页面的URL,结尾是不是带了.flv,去掉就可以播放了

去掉也不能播放的。

zzgghhzzgghh commented 1 year ago

我也遇到同样问题,求解 我也遇到同样问题,求解

bigbeer1 commented 1 year ago

我看了下内容 必须是 H.264的推流 编码率必须2048 超过容易丢包。

qian-jiang commented 1 year ago

我也遇到同样问题,求解