From 6cabd70c1c1ce3a2543b6dfd75b6f8011efc457d Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 21 Mar 2025 13:59:13 +0100 Subject: [PATCH] hopefully fix audio parameters --- src/transcoder.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/transcoder.rs b/src/transcoder.rs index 3e78e1d..b11ba12 100644 --- a/src/transcoder.rs +++ b/src/transcoder.rs @@ -946,7 +946,7 @@ println!("encoder {} is not supported by output (expected {})", istr.id, istr.ge let enc_stream = ret.unwrap(); //todo check for params mismatch let real_fmt = enc_stream.get_info().get_properties(); - let enc_ctx: Box = match (&oopts.enc_params.format, &real_fmt) { + let enc_ctx: Box = match (&oopts.enc_params.format, &ret_eparams.format) { (NACodecTypeInfo::Video(svinfo), NACodecTypeInfo::Video(dvinfo)) => { let force_cfr = self.fixed_rate || (ret_eparams.flags & ENC_MODE_CFR) != 0; if force_cfr && enc_stream.tb_den / enc_stream.tb_num > 120 { @@ -988,8 +988,14 @@ println!("encoder {} is not supported by output (expected {})", istr.id, istr.ge }) } }, - (NACodecTypeInfo::Audio(sainfo), NACodecTypeInfo::Audio(dainfo)) => { - if sainfo == dainfo { + (NACodecTypeInfo::Audio(sainfo), NACodecTypeInfo::Audio(ref_dainfo)) => { + let mut dainfo = *ref_dainfo; + if &oopts.enc_name == "pcm" { + if let NACodecTypeInfo::Audio(oformat) = real_fmt { + dainfo.block_len = oformat.block_len; + } + } + if sainfo == &dainfo { Box::new(AudioEncodeContext { encoder, cvt: None }) } else { let dchmap = match dainfo.channels { @@ -1000,8 +1006,9 @@ println!("can't generate default channel map for {} channels", dainfo.channels); return RegisterResult::Failed; }, }; + //todo channelmap - let acvt = AudioConverter::new(sainfo, dainfo, dchmap); + let acvt = AudioConverter::new(sainfo, &dainfo, dchmap); Box::new(AudioEncodeContext { encoder, cvt: Some(acvt) }) } }, -- 2.39.5