[fix] rtsp send audio and video out of sync

pull/142/head
suizg
parent c0966137e1
commit cc7326ed67

@ -90,8 +90,14 @@
"gop_num": 0 //. 见rtmp.gop_num
},
"rtsp": {
"enable": true, //. 是否开启rtsp服务的监听目前只支持rtsp推流
"addr": ":5544" //. rtsp推流地址
"enable": true, //. 是否开启rtsp服务的监听目前只支持rtsp推流
"addr": ":5544", //. rtsp推流地址
"out_wait_key_frame_flag": true //. rtsp出包时是否等待视频关键帧
// 音频和视频需要同时出,如果音频先出,而视频等待关键帧会导致音画不同步问题,两种情况:
// 1. 不等待视频关键帧,音视频包到了就转发
//
// 2. 等待视频关键帧,视频关键帧到达之前,丢弃音频数据。
// (存在音视频头,但是音频先到,视频晚到的场景等待关键帧会导致超时问题)
},
"record": {
"enable_flv": true, //. 是否开启flv录制

@ -40,7 +40,8 @@
},
"rtsp": {
"enable": true,
"addr": ":5544"
"addr": ":5544",
"out_wait_key_frame_flag": true
},
"record": {
"enable_flv": false,

@ -84,8 +84,9 @@ type HlsConfig struct {
}
type RtspConfig struct {
Enable bool `json:"enable"`
Addr string `json:"addr"`
Enable bool `json:"enable"`
Addr string `json:"addr"`
OutWaitKeyFrameFlag bool `json:"out_wait_key_frame_flag"`
}
type RecordConfig struct {

@ -381,8 +381,8 @@ func (group *Group) broadcastByRtmpMsg(msg base.RtmpMsg) {
// ---------------------------------------------------------------------------------------------------------------------
func (group *Group) feedRtpPacket(pkt rtprtcp.RtpPacket) {
// 音频直接发送
if group.sdpCtx.IsAudioPayloadTypeOrigin(int(pkt.Header.PacketType)) {
// 出包时不等待视频关键帧
if !group.config.RtspConfig.OutWaitKeyFrameFlag {
for s := range group.rtspSubSessionSet {
s.WriteRtpPacket(pkt)
}

Loading…
Cancel
Save