Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] rtsp send audio and video out of sync #142

Merged
merged 1 commit into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions conf/ConfigBrief.md
Original file line number Diff line number Diff line change
Expand Up @@ -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录制
Expand Down
3 changes: 2 additions & 1 deletion conf/lalserver.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
},
"rtsp": {
"enable": true,
"addr": ":5544"
"addr": ":5544",
"out_wait_key_frame_flag": true
},
"record": {
"enable_flv": false,
Expand Down
5 changes: 3 additions & 2 deletions pkg/logic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/logic/group__core_streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down