]> git.nihav.org Git - nihav.git/commitdiff
wav: generate PTS for demuxed blocks
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 3 Oct 2020 15:51:58 +0000 (17:51 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 3 Oct 2020 15:51:58 +0000 (17:51 +0200)
nihav-commonfmt/src/demuxers/wav.rs

index ce6318a6a41dd292015102aaae23611df91b541e..fb522cd1b82ca0daa94c6a777a49a05e211022a4 100644 (file)
@@ -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 {