fix: preserve audio samples across Miruro timestamp jitter

This commit is contained in:
2026-10-13 16:13:33 +02:00
parent 51382bc63a
commit 4ef8ceee24
6 changed files with 11 additions and 5 deletions
+4 -2
View File
@@ -1032,8 +1032,10 @@ struct Player {
}
const double timestamp = framePts(track, decoded);
const double tick = av_q2d(track.stream()->time_base);
const bool contiguous = continuing && std::abs(timestamp - track.nextPts) <= tick + 1.0 / rate;
// Quantized packet PTS and rounded resampler delay must not insert/drop PCM samples.
// Some TS muxers round timestamps to milliseconds despite a 90 kHz timebase.
// Allow two rounded endpoints of jitter; real gaps still insert silence.
const bool contiguous = continuing &&
std::abs(timestamp - track.nextPts) <= std::max(tick, 0.002) + 1.0 / rate;
const int64_t delayBase = static_cast<int64_t>(rate) * sampleRate;
pcmPts = contiguous ? resampleNextPts :
timestamp - static_cast<double>(swr_get_delay(resampler, delayBase)) / delayBase;