From 1a9161902f398c0c6ac3aec19c147492fa5414fb Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 10 Apr 2026 19:36:57 +0200 Subject: [PATCH] improve displayed time a bit --- src/main.rs | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main.rs b/src/main.rs index 015cbe3..feb3441 100644 --- a/src/main.rs +++ b/src/main.rs @@ -725,31 +725,14 @@ fn main() { pkt.reassign(newstream, ts); transcoder.debug_log(DebugLog::DEMUX, &format!(" Got packet from input stream {src_id} ts {ts:?}")); - if transcoder.verbose > 0 && time.elapsed() >= show_interval { - if let Some(pts) = pkt.get_pts() { - let cur_time = format_time(NATimeInfo::rescale_ts(pts, pkt.ts.tb_num, pkt.ts.tb_den, 1, 1000)); - print!(" {}", cur_time); - last_known_time = Some(cur_time); - } else if let Some(ref time) = last_known_time { - print!(" {time}"); - } else { - print!(" ???"); - } - if !duration_string.is_empty() { - print!(" / {}", duration_string); - } - if transcoder.verbose > 1 { - print!(" data sizes V: {} A: {}", vdata_size, adata_size); - } - print!("\r"); - std::io::stdout().flush().unwrap(); - time = Instant::now(); - } match transcoder.encoders[src_id] { OutputMode::Drop => { transcoder.debug_log(DebugLog::ENCODE, &format!(" Packet from stream {src_id} dropped")); }, OutputMode::Copy(dst_id) => { + if let Some(pts) = pkt.ts.pts { + last_known_time = Some(NATimeInfo::rescale_ts(pts, pkt.ts.tb_num, pkt.ts.tb_den, 1, 1000)); + } if mux_quirks.is_global_pal() && pkt.ts.pts != Some(0) && pkt.side_data.iter().any(|sd| matches!(sd, NASideData::Palette(true, _))) { println!("Palette change encountered while muxer does not support that!"); @@ -768,6 +751,9 @@ fn main() { transcoder.queue.queue_packet(pkt, &mut transcoder.debug); }, OutputMode::Encode(dst_id, ref mut encoder) => { + if let Some(pts) = pkt.ts.pts { + last_known_time = Some(NATimeInfo::rescale_ts(pts, pkt.ts.tb_num, pkt.ts.tb_den, 1, 1000)); + } if mux_quirks.is_global_pal() && pkt.ts.pts != Some(0) && pkt.side_data.iter().any(|sd| matches!(sd, NASideData::Palette(true, _))) { println!("Palette change encountered while muxer does not support that!"); @@ -816,6 +802,23 @@ fn main() { }, }; + if transcoder.verbose > 0 && time.elapsed() >= show_interval { + if let Some(time) = last_known_time { + print!(" {}", format_time(time)); + } else { + print!(" ???"); + } + if !duration_string.is_empty() { + print!(" / {}", duration_string); + } + if transcoder.verbose > 1 { + print!(" data sizes V: {} A: {}", vdata_size, adata_size); + } + print!("\r"); + std::io::stdout().flush().unwrap(); + time = Instant::now(); + } + if !retrieve_packets(&mut transcoder, &mut mux, &mut vdata_size, &mut adata_size, false) { break; } -- 2.39.5