From 3de5d3bf1a36ab0eae202254ba88e81af4fb8a6e Mon Sep 17 00:00:00 2001 From: Dave Johansen Date: Wed, 25 Oct 2023 09:35:30 -0600 Subject: [PATCH 1/2] Set time_base for AudioResampler --- av/audio/resampler.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/av/audio/resampler.pyx b/av/audio/resampler.pyx index b1c6c0aad..a0d49662f 100644 --- a/av/audio/resampler.pyx +++ b/av/audio/resampler.pyx @@ -75,7 +75,8 @@ cdef class AudioResampler(object): abuffer = self.graph.add("abuffer", sample_rate=str(frame.sample_rate), sample_fmt=AudioFormat(frame.format).name, - channel_layout=frame.layout.name) + channel_layout=frame.layout.name, + time_base=str(frame.time_base)) aformat = self.graph.add("aformat", sample_rates=str(self.rate), sample_fmts=self.format.name, From 1a997fe658206d15642ac7ed848597e254a218f9 Mon Sep 17 00:00:00 2001 From: Dave Johansen Date: Wed, 25 Oct 2023 14:04:03 -0600 Subject: [PATCH 2/2] Only pass time_base if it's not None --- av/audio/resampler.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/av/audio/resampler.pyx b/av/audio/resampler.pyx index a0d49662f..359a4a5bc 100644 --- a/av/audio/resampler.pyx +++ b/av/audio/resampler.pyx @@ -72,11 +72,14 @@ cdef class AudioResampler(object): # handle resampling with aformat filter # (similar to configure_output_audio_filter from ffmpeg) self.graph = av.filter.Graph() + extra_args = {} + if frame.time_base is not None: + extra_args["time_base"] = str(frame.time_base) abuffer = self.graph.add("abuffer", sample_rate=str(frame.sample_rate), sample_fmt=AudioFormat(frame.format).name, channel_layout=frame.layout.name, - time_base=str(frame.time_base)) + **extra_args) aformat = self.graph.add("aformat", sample_rates=str(self.rate), sample_fmts=self.format.name,