From b4bf2c3f1a94b2b4ebbfc704e17fbaf366f8fa8b Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 3 Oct 2020 17:51:58 +0200 Subject: [PATCH] wav: generate PTS for demuxed blocks --- nihav-commonfmt/src/demuxers/wav.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nihav-commonfmt/src/demuxers/wav.rs b/nihav-commonfmt/src/demuxers/wav.rs index ce6318a..fb522cd 100644 --- a/nihav-commonfmt/src/demuxers/wav.rs +++ b/nihav-commonfmt/src/demuxers/wav.rs @@ -68,7 +68,13 @@ impl<'a> DemuxCore<'a> for WAVDemuxer<'a> { let str = strmgr.get_stream(0); if str.is_none() { return Err(InvalidData); } let stream = str.unwrap(); - let ts = NATimeInfo::new(None, None, None, 1, self.srate); + let pts = if self.avg_bytes != 0 { + let pos = self.src.tell() - self.data_pos; + Some(pos * u64::from(self.srate) / u64::from(self.avg_bytes)) + } else { + None + }; + let ts = NATimeInfo::new(pts, None, None, 1, self.srate); if self.is_pcm { let mut bsize = self.block_size; while bsize < 256 { -- 2.39.5