mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
MP4: 修复mp4解复用定时器精度太高时读取文件太快的bug
This commit is contained in:
parent
b3dd440151
commit
f4b6a6bd40
@ -59,17 +59,15 @@ bool MP4Reader::readSample() {
|
|||||||
|
|
||||||
bool keyFrame = false;
|
bool keyFrame = false;
|
||||||
bool eof = false;
|
bool eof = false;
|
||||||
while (!eof) {
|
while (!eof && _last_dts < getCurrentStamp()) {
|
||||||
auto frame = _demuxer->readFrame(keyFrame, eof);
|
auto frame = _demuxer->readFrame(keyFrame, eof);
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
_last_dts = frame->dts();
|
||||||
if (_muxer) {
|
if (_muxer) {
|
||||||
_muxer->inputFrame(frame);
|
_muxer->inputFrame(frame);
|
||||||
}
|
}
|
||||||
if (frame->dts() > getCurrentStamp()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_CONFIG(bool, fileRepeat, Record::kFileRepeat);
|
GET_CONFIG(bool, fileRepeat, Record::kFileRepeat);
|
||||||
@ -129,6 +127,7 @@ uint32_t MP4Reader::getCurrentStamp() {
|
|||||||
void MP4Reader::setCurrentStamp(uint32_t new_stamp){
|
void MP4Reader::setCurrentStamp(uint32_t new_stamp){
|
||||||
auto old_stamp = getCurrentStamp();
|
auto old_stamp = getCurrentStamp();
|
||||||
_seek_to = new_stamp;
|
_seek_to = new_stamp;
|
||||||
|
_last_dts = new_stamp;
|
||||||
_seek_ticker.resetTime();
|
_seek_ticker.resetTime();
|
||||||
if (old_stamp != new_stamp && _muxer) {
|
if (old_stamp != new_stamp && _muxer) {
|
||||||
//时间轴未拖动时不操作
|
//时间轴未拖动时不操作
|
||||||
|
@ -60,6 +60,7 @@ private:
|
|||||||
bool _have_video = false;
|
bool _have_video = false;
|
||||||
bool _paused = false;
|
bool _paused = false;
|
||||||
float _speed = 1.0;
|
float _speed = 1.0;
|
||||||
|
uint32_t _last_dts = 0;
|
||||||
uint32_t _seek_to;
|
uint32_t _seek_to;
|
||||||
string _file_path;
|
string _file_path;
|
||||||
recursive_mutex _mtx;
|
recursive_mutex _mtx;
|
||||||
|
Loading…
Reference in New Issue
Block a user