pub fn write_pgmyuv(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
if let NABufferType::None = frm.get_buffer() { return; }
- let name = format!("{}out{:02}_{:08}.pgm", pfx, strno, num);
+ let name = format!("{}{:02}_{:08}.pgm", pfx, strno, num);
let mut ofile = File::create(name).unwrap();
let buf = frm.get_buffer().get_vbuf().unwrap();
let is_flipped = buf.get_info().is_flipped();
}
pub fn write_palppm(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
- let name = format!("{}out{:02}_{:08}.ppm", pfx, strno, num);
+ let name = format!("{}{:02}_{:08}.ppm", pfx, strno, num);
let mut ofile = File::create(name).unwrap();
let buf = frm.get_buffer().get_vbuf().unwrap();
let (w, h) = buf.get_dimensions(0);
}
pub fn write_ppm(pfx: &str, strno: usize, num: u64, frm: NAFrameRef) {
- let name = format!("{}out{:02}_{:08}.ppm", pfx, strno, num);
+ let name = format!("{}{:02}_{:08}.ppm", pfx, strno, num);
let mut ofile = File::create(name).unwrap();
let info = frm.get_buffer().get_video_info().unwrap();
let flipped = info.is_flipped();
}
struct FrameOutput {
- prefix: &'static str,
+ prefix: String,
streamno: usize,
frameno: u64,
nmode: NumberMode,
};
let vinfo = frm.get_buffer().get_video_info().unwrap();
if vinfo.get_format().is_paletted() {
- write_palppm(self.prefix, self.streamno, pts, frm);
+ write_palppm(&self.prefix, self.streamno, pts, frm);
} else if vinfo.get_format().get_model().is_yuv() {
- write_pgmyuv(self.prefix, self.streamno, pts, frm);
+ write_pgmyuv(&self.prefix, self.streamno, pts, frm);
} else if vinfo.get_format().get_model().is_rgb() {
- write_ppm(self.prefix, self.streamno, pts, frm);
+ write_ppm(&self.prefix, self.streamno, pts, frm);
} else {
panic!(" unknown format");
}
let mut decode_audio = true;
let mut nmode = NumberMode::FrmPTS;
let mut seek_time = 0u64;
+ let mut vpfx: Option<String> = None;
+ let mut apfx: Option<&str> = None;
while (cur_arg < args.len()) && args[cur_arg].starts_with('-') {
match args[cur_arg].as_str() {
}
seek_time = ret.unwrap();
},
+ "-apfx" => {
+ cur_arg += 1;
+ if cur_arg == args.len() {
+ println!("name missing");
+ return;
+ }
+ apfx = Some(&args[cur_arg]);
+ },
+ "-vpfx" => {
+ cur_arg += 1;
+ if cur_arg == args.len() {
+ println!("name missing");
+ return;
+ }
+ vpfx = Some(args[cur_arg].clone());
+ },
_ => { println!("unknown option {}", args[cur_arg]); return; },
}
cur_arg += 1;
dec.init(&mut dsupp, info).unwrap();
decs.push(Some((dsupp, dec)));
if !noout {
- writers.push(Outputter::Video(FrameOutput{prefix: "", streamno: i, frameno: 1, nmode}));
+ writers.push(Outputter::Video(FrameOutput{prefix: if let Some(ref str) = vpfx { str.clone() } else { "out".to_string() }, streamno: i, frameno: 1, nmode}));
has_out = true;
}
} else {
dec.init(&mut dsupp, info).unwrap();
decs.push(Some((dsupp, dec)));
if !noout {
- let name = format!("out{:02}.wav", i);
+ let name = if let Some(apfx) = apfx {
+ format!("{}{:02}.wav", apfx, i)
+ } else {
+ format!("out{:02}.wav", i)
+ };
writers.push(Outputter::Audio(AudioOutput::new(&name)));
has_out = true;
}