diff --git a/lib/dtscmeta.cpp b/lib/dtscmeta.cpp index 795c2557..705effeb 100644 --- a/lib/dtscmeta.cpp +++ b/lib/dtscmeta.cpp @@ -1374,6 +1374,7 @@ namespace DTSC { } void Meta::update(long long packTime, long long packOffset, long long packTrack, long long packDataSize, long long packBytePos, bool isKeyframe, long long packSendSize, unsigned long segment_size, const char * ivec){ + DONTEVEN_MSG("Updating meta with: t=%lld, o=%lld, s=%lld, t=%lld, p=%lld", packTime, packOffset, packDataSize, packTrack, packBytePos); if (!packSendSize){ //time and trackID are part of the 20-byte header. //the container object adds 4 bytes (plus 2+namelen for each content, see below) diff --git a/src/input/input_mp4.cpp b/src/input/input_mp4.cpp index a9c3bf4b..ff652ed1 100644 --- a/src/input/input_mp4.cpp +++ b/src/input/input_mp4.cpp @@ -23,6 +23,7 @@ namespace Mist { offsetIndex = 0; offsetPos = 0; sttsBox.clear(); + hasCTTS = false; cttsBox.clear(); stszBox.clear(); stcoBox.clear(); @@ -75,6 +76,7 @@ namespace Mist { tmp = std::string(stblLoopPeek.asBox() ,stblLoopPeek.boxedSize()); cttsBox.clear(); cttsBox.read(tmp); + hasCTTS = true; }else if (stblBoxType == "stsz"){ tmp = std::string(stblLoopPeek.asBox() ,stblLoopPeek.boxedSize()); stszBox.clear(); @@ -163,15 +165,17 @@ namespace Mist { offsetIndex = 0; offsetPos = 0; } - MP4::CTTSEntry tmpCTTS; - while (offsetIndex < cttsBox.getEntryCount()){ - tmpCTTS = cttsBox.getCTTSEntry(offsetIndex); - if ((index - offsetPos) < tmpCTTS.sampleCount){ - timeOffset = (tmpCTTS.sampleOffset*1000)/timeScale; - break; + if (hasCTTS){ + MP4::CTTSEntry tmpCTTS; + while (offsetIndex < cttsBox.getEntryCount()){ + tmpCTTS = cttsBox.getCTTSEntry(offsetIndex); + if ((index - offsetPos) < tmpCTTS.sampleCount){ + timeOffset = (tmpCTTS.sampleOffset*1000)/timeScale; + break; + } + offsetPos += tmpCTTS.sampleCount; + ++offsetIndex; } - offsetPos += tmpCTTS.sampleCount; - ++offsetIndex; } //next lines are common for next-getting and seeking diff --git a/src/input/input_mp4.h b/src/input/input_mp4.h index 4c842d86..2a3ac9e8 100644 --- a/src/input/input_mp4.h +++ b/src/input/input_mp4.h @@ -63,6 +63,7 @@ namespace Mist { MP4::STCO stcoBox; MP4::STSZ stszBox; MP4::STTS sttsBox; + bool hasCTTS; MP4::CTTS cttsBox; MP4::STSC stscBox; long unsigned int timeScale; diff --git a/src/io.cpp b/src/io.cpp index 5a2a141b..2cf80477 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -264,6 +264,7 @@ namespace Mist { } //Save the current write position size_t curOffset = pagesByTrack[tid][curPageNum[tid]].curOffset; + DONTEVEN_MSG("Buffering packet on page %lu for track %lu~>%lu: %d bytes @ %lu: %s", curPageNum[tid], tid, mapTid, pack.getDataLen(), curOffset); //Do nothing when there is not enough free space on the page to add the packet. if (pagesByTrack[tid][curPageNum[tid]].dataSize - curOffset < pack.getDataLen()) { FAIL_MSG("Trying to buffer a packet on page %lu for track %lu~>%lu, but we have a size mismatch. The packet is %d bytes long, so won't fit at offset %lu on a page of %llu bytes!", curPageNum[tid], tid, mapTid, pack.getDataLen(), curOffset, pagesByTrack[tid][curPageNum[tid]].dataSize);