Skip to content

Commit 200a55e

Browse files
EwoutHtdaede
authored andcommitted
Add estimated time and 3rd decimal to fps in CLI output
1 parent a14b6fa commit 200a55e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/bin/common.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,13 @@ impl ProgressInfo {
492492
.map(|frames| self.encoded_size * frames / self.frames_encoded())
493493
.unwrap_or_default()
494494
}
495+
496+
// Estimates the remaining encoding time in seconds, if the number of frames is known
497+
pub fn estimated_time(&self) -> f64 {
498+
self.total_frames
499+
.map(|frames| (frames - self.frames_encoded()) as f64 / self.encoding_fps())
500+
.unwrap_or_default()
501+
}
495502

496503
// Number of frames of given type which appear in the video
497504
pub fn get_frame_type_count(&self, frame_type: FrameType) -> usize {
@@ -558,17 +565,18 @@ impl fmt::Display for ProgressInfo {
558565
if let Some(total_frames) = self.total_frames {
559566
write!(
560567
f,
561-
"encoded {}/{} frames, {:.2} fps, {:.2} Kb/s, est. size: {:.2} MB",
568+
"encoded {}/{} frames, {:.3} fps, {:.2} Kb/s, est. size: {:.2} MB, est. time: {:.0} s",
562569
self.frames_encoded(),
563570
total_frames,
564571
self.encoding_fps(),
565572
self.bitrate() as f64 / 1024f64,
566-
self.estimated_size() as f64 / (1024 * 1024) as f64
573+
self.estimated_size() as f64 / (1024 * 1024) as f64,
574+
self.estimated_time()
567575
)
568576
} else {
569577
write!(
570578
f,
571-
"encoded {} frames, {:.2} fps, {:.2} Kb/s",
579+
"encoded {} frames, {:.3} fps, {:.2} Kb/s",
572580
self.frames_encoded(),
573581
self.encoding_fps(),
574582
self.bitrate() as f64 / 1024f64

0 commit comments

Comments
 (0)