srt push check audio and video timestamp sync

This commit is contained in:
xiongguangjie 2023-03-25 20:32:21 +08:00
parent ca7efd5941
commit a390042f38

View File

@ -288,6 +288,14 @@ bool SrtTransportImp::inputFrame(const Frame::Ptr &frame) {
if (_muxer) { if (_muxer) {
//TraceL<<"before type "<<frame->getCodecName()<<" dts "<<frame->dts()<<" pts "<<frame->pts(); //TraceL<<"before type "<<frame->getCodecName()<<" dts "<<frame->dts()<<" pts "<<frame->pts();
auto frame_tmp = std::make_shared<FrameStamp>(frame, _type_to_stamp[frame->getTrackType()],false); auto frame_tmp = std::make_shared<FrameStamp>(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 : "<<diff;
}
}
//TraceL<<"after type "<<frame_tmp->getCodecName()<<" dts "<<frame_tmp->dts()<<" pts "<<frame_tmp->pts(); //TraceL<<"after type "<<frame_tmp->getCodecName()<<" dts "<<frame_tmp->dts()<<" pts "<<frame_tmp->pts();
return _muxer->inputFrame(frame_tmp); return _muxer->inputFrame(frame_tmp);
} }