From d940f0c273d4f783e5ec5509e7006322f6d33e05 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 6 Jul 2020 14:15:38 +0200 Subject: [PATCH] mov: take audio frame size/length into account while demuxing --- nihav-commonfmt/src/demuxers/mov.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index 19a602f..4904697 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -846,8 +846,14 @@ impl Track { self.last_offset += size as u64; if self.stream_type == StreamType::Video { self.samples_left -= 1; - } else if self.frame_samples != 0 { - self.samples_left -= self.frame_samples.min(self.samples_left); + } else if self.frame_samples != 0 && self.bsize != 0 { + let nblocks = size / self.bsize; + if nblocks > 0 { + let consumed = (nblocks * self.frame_samples).min(self.samples_left); + self.samples_left -= consumed; + } else { + self.samples_left = 0; + } } else { self.samples_left = 0; } -- 2.39.5