cleaner pts rescaling at packet write time. writing headers can change time_base by design so just adapt to it

This commit is contained in:
Viv Lim 2021-07-26 01:10:48 -07:00
parent ea771c8dd7
commit ee9678af68
1 changed files with 1 additions and 8 deletions

View File

@ -253,14 +253,7 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
//if encoded_packet.size() > 0 { //if encoded_packet.size() > 0 {
encoded_packet.set_stream(stream_index); encoded_packet.set_stream(stream_index);
eprintln!("📦 Writing packet, pts {:?} dts {:?} size {}", encoded_packet.pts(), encoded_packet.dts(), encoded_packet.size()); 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), self.octx.stream(stream_index).unwrap().time_base());
//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));
}
eprintln!("📦 rescaled , pts {:?} dts {:?} size {}", encoded_packet.pts(), encoded_packet.dts(), encoded_packet.size()); eprintln!("📦 rescaled , pts {:?} dts {:?} size {}", encoded_packet.pts(), encoded_packet.dts(), encoded_packet.size());
match encoded_packet.write_interleaved(&mut self.octx) { match encoded_packet.write_interleaved(&mut self.octx) {