mux_opts: Vec<OptionArgs>,
istr_opts: Vec<InputStreamOptions>,
ostr_opts: Vec<OutputStreamOptions>,
+ scale_opts: Vec<(String, String)>,
decoders: Vec<Option<(Box<NADecoderSupport>, Box<dyn NADecoder>, Box<dyn FrameReorderer>)>>,
encoders: Vec<OutputMode>,
no_video: bool,
}
true
}
+ fn parse_scale_options(&mut self, opts: &str) -> bool {
+ for opt in opts.split(',') {
+ let oval: Vec<_> = opt.split('=').collect();
+ if oval.len() == 1 {
+ self.scale_opts.push((oval[0].to_string(), "".to_string()));
+ } else if oval.len() == 2 {
+ self.scale_opts.push((oval[0].to_string(), oval[1].to_string()));
+ } else {
+ println!("unrecognized option '{}'", opt);
+ return false;
+ }
+ }
+ true
+ }
fn apply_decoder_options(&self, dec: &mut dyn NADecoder, str_id: u32) {
if let Some(str_idx) = self.istr_opts.iter().position(|str| str.id == str_id) {
let dec_opts = dec.get_supported_options();
OutputConvert::None
} else {
let ofmt = ScaleInfo { fmt: dvinfo.format, width: dvinfo.width, height: dvinfo.height };
- let ret = NAScale::new(ofmt, ofmt);
+ let ret = NAScale::new_with_options(ofmt, ofmt, &self.scale_opts);
if ret.is_err() {
println!("cannot create scaler");
return false;
}
}
-fn encode_frame(dst_id: u32, encoder: &mut Box<dyn NAEncoder>, cvt: &mut OutputConvert, frm: NAFrameRef) -> bool {
+fn encode_frame(dst_id: u32, encoder: &mut Box<dyn NAEncoder>, cvt: &mut OutputConvert, frm: NAFrameRef, scale_opts: &[(String, String)]) -> bool {
let buf = frm.get_buffer();
let cbuf = match cvt {
OutputConvert::None => buf,
let last_ifmt = scaler.get_in_fmt();
if cur_ifmt != last_ifmt {
let ofmt = scaler.get_out_fmt();
- let ret = NAScale::new(cur_ifmt, ofmt);
+ let ret = NAScale::new_with_options(cur_ifmt, ofmt, scale_opts);
if ret.is_err() {
println!("error re-initialising scaler for {} -> {}", cur_ifmt, ofmt);
return false;
println!(" --input inputfile - set input file");
println!(" --input-format fmt - force input format");
println!(" --demuxer-options options - set input demuxer options");
+ println!(" --scale-options options - set scaler options");
println!(" --output outputfile - set output file");
println!(" --output-format fmt - force output format");
println!(" --muxer-options options - set output muxer options");
return;
}
},
+ "--scale-options" => {
+ next_arg!(args, arg_idx);
+ if !transcoder.parse_scale_options(&args[arg_idx]) {
+ println!("invalid scale option syntax");
+ return;
+ }
+ },
"--no-video" | "-vn" => {
transcoder.no_video = true;
},
let frm = ret.unwrap();
reorderer.add_frame(frm);
while let Some(frm) = reorderer.get_frame() {
- if !encode_frame(dst_id, encoder, cvt, frm) {
+ if !encode_frame(dst_id, encoder, cvt, frm, &transcoder.scale_opts) {
break;
}
while let Ok(Some(pkt)) = encoder.get_packet() {
if let OutputMode::Encode(dst_id, ref mut encoder, ref mut cvt) = transcoder.encoders[src_id] {
if let Some((_, _, ref mut reorderer)) = transcoder.decoders[src_id] {
while let Some(frm) = reorderer.get_last_frames() {
- if !encode_frame(dst_id, encoder, cvt, frm) {
+ if !encode_frame(dst_id, encoder, cvt, frm, &transcoder.scale_opts) {
break;
}
while let Ok(Some(pkt)) = encoder.get_packet() {