From: Kostya Shishkov Date: Sat, 25 Apr 2026 08:52:27 +0000 (+0200) Subject: set pixel format to pal8 if palettisation is requested X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=7cf58d4d27cc447ff4a4f0cf91b2b1343f260270;p=nihav-encoder.git set pixel format to pal8 if palettisation is requested --- diff --git a/src/transcoder.rs b/src/transcoder.rs index 7fcbf0d..b70981e 100644 --- a/src/transcoder.rs +++ b/src/transcoder.rs @@ -974,12 +974,6 @@ impl Transcoder { dainfo.format = SND_S16_FORMAT; } } - let ret_eparams = encoder.negotiate_format(&oopts.enc_params); - if ret_eparams.is_err() { - println!("cannot negotiate encoding parameters"); - return None; - } - let ret_eparams = ret_eparams.unwrap(); let mut plt = create_palettiser(&oopts.enc_opts); oopts.enc_opts.retain(|opt| !opt.name.starts_with("pal.")); @@ -993,6 +987,22 @@ impl Transcoder { } } + if plt.is_some() { + if let NACodecTypeInfo::Video(ref mut vinfo) = oopts.enc_params.format { + if !vinfo.format.is_paletted() { + println!(" warning: output stream did not specify paletted output, setting pixfmt=pal8"); + vinfo.format = PAL8_FORMAT; + } + } + } + + let ret_eparams = encoder.negotiate_format(&oopts.enc_params); + if ret_eparams.is_err() { + println!("cannot negotiate encoding parameters"); + return None; + } + let ret_eparams = ret_eparams.unwrap(); + let name = format!("output stream {}", out_id); parse_and_apply_options!(encoder, &oopts.enc_opts, name);