mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-16 13:05:59 +08:00
媒体时间戳默认改为相对时间戳,通过时间戳矫正器解决跳跃和回退问题 (#2523)
通过用户反馈发现,遇到较多直播源时间戳混乱问题,包括rtsp流之rtcp ntp时间戳混乱,国标流时间戳混乱问题。 之前默认采用源流绝对时间戳,但是由于时间戳混乱会导致hls切片异常或视频播放不了等问题。 故默认改成相对时间戳(modify_stamp=2),通过时间戳矫正器过滤了时间戳跳跃以及回退问题(强制加1ms), 同时保留了对之前时间戳覆盖(modify_stamp=1)的兼容。 该修改同时兼容点播流,在点播流开启时间戳覆盖时,不起实质作用(采用原始绝对时间戳)。
This commit is contained in:
@@ -94,6 +94,11 @@ MultiMediaSourceMuxer::MultiMediaSourceMuxer(const MediaTuple& tuple, float dur_
|
||||
_poller = EventPollerPool::Instance().getPoller();
|
||||
_create_in_poller = _poller->isCurrentThread();
|
||||
_option = option;
|
||||
if (dur_sec > 0.01) {
|
||||
// 点播
|
||||
_stamp[TrackVideo].setPlayBack();
|
||||
_stamp[TrackAudio].setPlayBack();
|
||||
}
|
||||
|
||||
if (option.enable_rtmp) {
|
||||
_rtmp = std::make_shared<RtmpMediaSourceMuxer>(_tuple, option, std::make_shared<TitleMeta>(dur_sec));
|
||||
@@ -378,6 +383,11 @@ void MultiMediaSourceMuxer::onAllTrackReady() {
|
||||
createGopCacheIfNeed();
|
||||
}
|
||||
#endif
|
||||
auto tracks = getTracks(false);
|
||||
if (tracks.size() >= 2) {
|
||||
// 音频时间戳同步于视频,因为音频时间戳被修改后不影响播放
|
||||
_stamp[TrackAudio].syncTo(_stamp[TrackVideo]);
|
||||
}
|
||||
InfoL << "stream: " << shortUrl() << " , codec info: " << getTrackInfoStr(this);
|
||||
}
|
||||
|
||||
@@ -429,9 +439,9 @@ void MultiMediaSourceMuxer::resetTracks() {
|
||||
|
||||
bool MultiMediaSourceMuxer::onTrackFrame(const Frame::Ptr &frame_in) {
|
||||
auto frame = frame_in;
|
||||
if (_option.modify_stamp) {
|
||||
//开启了时间戳覆盖
|
||||
frame = std::make_shared<FrameStamp>(frame, _stamp[frame->getTrackType()],true);
|
||||
if (_option.modify_stamp != ProtocolOption::kModifyStampOff) {
|
||||
// 时间戳不采用原始的绝对时间戳
|
||||
frame = std::make_shared<FrameStamp>(frame, _stamp[frame->getTrackType()], _option.modify_stamp);
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
|
||||
Reference in New Issue
Block a user