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