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(-)
@@ -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