From a390042f38bad43e0e2f578bddc56f63442cc0d7 Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Sat, 25 Mar 2023 20:32:21 +0800 Subject: [PATCH] srt push check audio and video timestamp sync --- srt/SrtTransportImp.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/srt/SrtTransportImp.cpp b/srt/SrtTransportImp.cpp index f5457e5f..5504714b 100644 --- a/srt/SrtTransportImp.cpp +++ b/srt/SrtTransportImp.cpp @@ -288,6 +288,14 @@ bool SrtTransportImp::inputFrame(const Frame::Ptr &frame) { if (_muxer) { //TraceL<<"before type "<getCodecName()<<" dts "<dts()<<" pts "<pts(); auto frame_tmp = std::make_shared(frame, _type_to_stamp[frame->getTrackType()],false); + if(_type_to_stamp.size()>1){ + // 有音视频,检查是否时间戳是否差距过大 + auto diff = _type_to_stamp[TrackType::TrackVideo].getRelativeStamp() - _type_to_stamp[TrackType::TrackAudio].getRelativeStamp(); + if(std::abs(diff) > 5000){ + // 超过5s,应该同步 TODO + WarnL << _media_info._full_url<<" video or audio not sync : "<getCodecName()<<" dts "<dts()<<" pts "<pts(); return _muxer->inputFrame(frame_tmp); }