Skip to content

Commit

Permalink
优化rtsp ntp时间戳,防止音视频不同步( ZLMediaKit#4017 ZLMediaKit#4018)
Browse files Browse the repository at this point in the history
rtp时间戳可能被截断,ntp时间戳生成时优先使用未截断的原始时间戳,防止音视频不同步
  • Loading branch information
ss002012 authored Nov 18, 2024
1 parent 51f49d3 commit 226b87a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/Rtsp/RtspMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ void RtspMuxer::onRtp(RtpPacket::Ptr in, bool is_key) {
if (ref.rtp_stamp != in->getHeader()->stamp) {
// rtp时间戳变化才计算ntp,节省cpu资源 [AUTO-TRANSLATED:729d54f2]
// Only calculate NTP when the RTP timestamp changes, saving CPU resources
int64_t stamp_ms = in->getStamp() * uint64_t(1000) / in->sample_rate;
int64_t stamp_ms_inc;
// 求rtp时间戳增量 [AUTO-TRANSLATED:f6ba022f]
// Get the RTP timestamp increment
ref.stamp.revise(stamp_ms, stamp_ms, stamp_ms_inc, stamp_ms_inc);
ref.stamp.revise(in->ntp_stamp, in->ntp_stamp, stamp_ms_inc, stamp_ms_inc);
ref.rtp_stamp = in->getHeader()->stamp;
ref.ntp_stamp = stamp_ms_inc + _ntp_stamp_start;
}
Expand Down

0 comments on commit 226b87a

Please sign in to comment.