mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
mp4切片逻辑提高对音视频交织性差的流的兼容性能
This commit is contained in:
parent
19c7d1c406
commit
a16b6cbc59
@ -96,19 +96,22 @@ void MP4Recorder::closeFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MP4Recorder::inputFrame(const Frame::Ptr &frame) {
|
bool MP4Recorder::inputFrame(const Frame::Ptr &frame) {
|
||||||
if (_last_dts == 0 || _last_dts > frame->dts()) {
|
if (!(_have_video && frame->getTrackType() == TrackAudio)) {
|
||||||
//极少情况下dts时间戳可能回退
|
//如果有视频且输入的是音频,那么应该忽略切片逻辑
|
||||||
_last_dts = frame->dts();
|
if (_last_dts == 0 || _last_dts > frame->dts()) {
|
||||||
}
|
//极少情况下dts时间戳可能回退
|
||||||
|
_last_dts = frame->dts();
|
||||||
|
}
|
||||||
|
|
||||||
auto duration = frame->dts() - _last_dts;
|
auto duration = frame->dts() - _last_dts;
|
||||||
if (!_muxer || ((duration > _max_second * 1000) && (!_have_video || (_have_video && frame->keyFrame())))) {
|
if (!_muxer || ((duration > _max_second * 1000) && (!_have_video || (_have_video && frame->keyFrame())))) {
|
||||||
//成立条件
|
//成立条件
|
||||||
//1、_muxer为空
|
// 1、_muxer为空
|
||||||
//2、到了切片时间,并且只有音频
|
// 2、到了切片时间,并且只有音频
|
||||||
//3、到了切片时间,有视频并且遇到视频的关键帧
|
// 3、到了切片时间,有视频并且遇到视频的关键帧
|
||||||
_last_dts = 0;
|
_last_dts = 0;
|
||||||
createFile();
|
createFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_muxer) {
|
if (_muxer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user