]> git.nihav.org Git - nihav-encoder.git/commitdiff
improve displayed time a bit
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 10 Apr 2026 17:36:57 +0000 (19:36 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 10 Apr 2026 17:36:57 +0000 (19:36 +0200)
src/main.rs

index 015cbe3eb69de736a917e774c2f5ac82cc7df1a6..feb3441d2fb2db16994b80b09a5df98b7c2d637f 100644 (file)
@@ -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;
         }