From ee9678af68355b866b13ceca621bfe84b2b8a327 Mon Sep 17 00:00:00 2001 From: Viv Lim Date: Mon, 26 Jul 2021 01:10:48 -0700 Subject: [PATCH] cleaner pts rescaling at packet write time. writing headers can change time_base by design so just adapt to it --- examples/ffmpeg_recorder.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/examples/ffmpeg_recorder.rs b/examples/ffmpeg_recorder.rs index 33cc495..e45ffa8 100644 --- a/examples/ffmpeg_recorder.rs +++ b/examples/ffmpeg_recorder.rs @@ -253,14 +253,7 @@ static bool ffmpeg_init_config(struct ff_config_param *params, //if encoded_packet.size() > 0 { encoded_packet.set_stream(stream_index); eprintln!("📦 Writing packet, pts {:?} dts {:?} size {}", encoded_packet.pts(), encoded_packet.dts(), encoded_packet.size()); - if let EncoderToWriteFrom::Video = encoder{ - //encoded_packet.rescale_ts(Rational(1, 60), Rational(1, 44100)); // slow, ~30fps - encoded_packet.rescale_ts(Rational(1, 60), Rational(1, 15360)); - } - if let EncoderToWriteFrom::Audio = encoder{ - //encoded_packet.rescale_ts(Rational(1, 60), Rational(1, 44100)); // slow, ~30fps - encoded_packet.rescale_ts(Rational(1, 60), Rational(1, 44100)); - } + encoded_packet.rescale_ts(Rational(1, 60), self.octx.stream(stream_index).unwrap().time_base()); eprintln!("📦 rescaled , pts {:?} dts {:?} size {}", encoded_packet.pts(), encoded_packet.dts(), encoded_packet.size()); match encoded_packet.write_interleaved(&mut self.octx) {