From 497234f4b2df05c75454181ffb2748090d3bf0d0 Mon Sep 17 00:00:00 2001 From: kieran Date: Mon, 18 Nov 2024 14:13:14 +0000 Subject: [PATCH] fix: assign pts in audio fifo --- src/audio_fifo.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/audio_fifo.rs b/src/audio_fifo.rs index c73a040..eee00e1 100644 --- a/src/audio_fifo.rs +++ b/src/audio_fifo.rs @@ -8,6 +8,7 @@ use ffmpeg_sys_the_third::{ pub struct AudioFifo { ctx: *mut AVAudioFifo, + pts: i64, } impl AudioFifo { @@ -16,7 +17,7 @@ impl AudioFifo { if ctx.is_null() { bail!("Could not allocate audio fifo"); } - Ok(Self { ctx }) + Ok(Self { ctx, pts: 0 }) } /// Buffer a resampled frame, and get a frame from the buffer with the desired size @@ -55,6 +56,11 @@ impl AudioFifo { av_frame_free(&mut out_frame); bail!("Failed to read audio frame"); } + + // assign PTS + (*out_frame).pts = self.pts; + self.pts += (*out_frame).nb_samples as i64; + Ok(Some(out_frame)) } else { Ok(None)