encoders: Vec<OutputMode>,
no_video: bool,
no_audio: bool,
+ start: NATimePoint,
+ end: NATimePoint,
}
macro_rules! parse_and_apply_options {
"--no-audio" => {
transcoder.no_audio = true;
},
+ "--start" => {
+ next_arg!(args, arg_idx);
+ let ret = args[arg_idx].parse::<NATimePoint>();
+ if let Ok(val) = ret {
+ transcoder.start = val;
+ } else {
+ println!("invalid start time");
+ return;
+ }
+ },
+ "--end" => {
+ next_arg!(args, arg_idx);
+ let ret = args[arg_idx].parse::<NATimePoint>();
+ if let Ok(val) = ret {
+ transcoder.end = val;
+ } else {
+ println!("invalid start time");
+ return;
+ }
+ },
"--muxer-options" => {
next_arg!(args, arg_idx);
if !transcoder.parse_muxer_options(&args[arg_idx], &mux_reg) {
transcoder.decoders.push(None);
}
}
+ if transcoder.start != NATimePoint::None {
+ let ret = dmx.seek(transcoder.start);
+ if ret.is_err() {
+ println!(" failed to seek to {} error {:?}", transcoder.start, ret.err().unwrap());
+ }
+ }
let output_fmt = if let Some(ref str) = transcoder.output_fmt {
str
println!(" #{}: {} {}", ostr.get_num(), ostr, ostr.get_info().get_name());
}
- loop {
+ 'main_loop: loop {
let pktres = dmx.get_frame();
if let Err(DemuxerError::EOF) = pktres { break; }
if pktres.is_err() {
OutputMode::Copy(dst_id) => {
let dstr = mux.get_stream(dst_id as usize).unwrap();
pkt.reassign(dstr, pkt.get_time_information());
+ if transcoder.end != NATimePoint::None && !pkt.ts.less_than(transcoder.end) { break 'main_loop; }
if mux.mux_frame(pkt).is_err() {
println!("error muxing packet");
break;
let cfrm = NAFrame::new(frm.get_time_information(), frm.frame_type, frm.key, frm.get_info(), cbuf);
encoder.encode(&cfrm).unwrap();
while let Ok(Some(pkt)) = encoder.get_packet() {
+ if transcoder.end != NATimePoint::None && !pkt.ts.less_than(transcoder.end) { break 'main_loop; }
mux.mux_frame(pkt).unwrap();
}
} else {