diff --git a/tsMuxer/hevcStreamReader.cpp b/tsMuxer/hevcStreamReader.cpp index 64b61516..292912a6 100644 --- a/tsMuxer/hevcStreamReader.cpp +++ b/tsMuxer/hevcStreamReader.cpp @@ -601,6 +601,12 @@ int HEVCStreamReader::intDecodeNAL(uint8_t* buff) if (m_eof) { m_lastDecodedPos = m_bufEnd; + if (sliceFound && !m_flush) + { + // we expect there will not be any more data because EOF is met, if we found any slice, we can update DTS + // PTS such that the found slice could be wrapped in a new PES + incTimings(); + } return 0; } return NEED_MORE_DATA; diff --git a/tsMuxer/mpegStreamReader.cpp b/tsMuxer/mpegStreamReader.cpp index dfdf6cc0..7354321f 100644 --- a/tsMuxer/mpegStreamReader.cpp +++ b/tsMuxer/mpegStreamReader.cpp @@ -36,6 +36,7 @@ void MPEGStreamReader::setBuffer(uint8_t* data, const uint32_t dataLen, const bo int MPEGStreamReader::flushPacket(AVPacket& avPacket) { m_eof = true; + m_flush = true; avPacket.codec = this; avPacket.duration = 0; avPacket.data = nullptr; diff --git a/tsMuxer/mpegStreamReader.h b/tsMuxer/mpegStreamReader.h index cb9acf5e..983841f7 100644 --- a/tsMuxer/mpegStreamReader.h +++ b/tsMuxer/mpegStreamReader.h @@ -15,6 +15,7 @@ class MPEGStreamReader : public AbstractStreamReader m_tmpBufferLen = 0; setFPS(0); m_eof = false; + m_flush = false; m_lastDecodeOffset = LONG_MAX; m_tmpBuffer = new uint8_t[TMP_BUFFER_SIZE]; m_lastDecodedPos = nullptr; @@ -66,6 +67,7 @@ class MPEGStreamReader : public AbstractStreamReader int64_t m_curDts; int64_t m_processedBytes; bool m_eof; + bool m_flush; double m_fps; int64_t m_pcrIncPerFrame; int64_t m_pcrIncPerField;