diff mbox series

[FFmpeg-devel] fftools/ffmpeg: fix clearing previous output

Message ID CAPYw7P744LjuMgjRfP+5ka+2QJyP+SvmR+Y9bh_gQUL0jK=FgQ@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] fftools/ffmpeg: fix clearing previous output | expand

Checks

Context Check Description
andriy/make_fate_x86 success Make fate finished
andriy/make_x86 warning New warnings during build

Commit Message

Paul B Mahol Jan. 29, 2023, 7:49 p.m. UTC
Patch attached.
diff mbox series

Patch

From 95efe0d6d7e6fe5e29e6372f2da38cfbc4453a83 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Sun, 29 Jan 2023 20:46:50 +0100
Subject: [PATCH] fftools/ffmpeg: fix clearing previous output

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 fftools/ffmpeg.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 9884e0c6c6..e39260ee90 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1539,6 +1539,7 @@  static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
     static int64_t last_time = -1;
     static int first_report = 1;
     static int qp_histogram[52];
+    static int prev_buf_len = -1;
     int hours, mins, secs, us;
     const char *hours_sign;
     int ret;
@@ -1696,11 +1697,14 @@  static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
 
     if (print_stats || is_last_report) {
         const char end = is_last_report ? '\n' : '\r';
+        if (prev_buf_len < 0)
+            prev_buf_len = buf.len;
         if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
             fprintf(stderr, "%s    %c", buf.str, end);
         } else
-            av_log(NULL, AV_LOG_INFO, "%s    %c", buf.str, end);
+            av_log(NULL, AV_LOG_INFO, "%s%*c%c", buf.str, -FFMAX(0, buf.len - prev_buf_len), ' ', end);
 
+        prev_buf_len = buf.len;
         fflush(stderr);
     }
     av_bprint_finalize(&buf, NULL);
-- 
2.39.1