diff mbox series

[FFmpeg-devel,1/2] fftools/ffmpeg.c: Use the streams from the first output in print_final_stats.

Message ID 20200626212830.1734049-1-wangcao@google.com
State New
Headers show
Series [FFmpeg-devel,1/2] fftools/ffmpeg.c: Use the streams from the first output in print_final_stats.
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Wang Cao June 26, 2020, 9:28 p.m. UTC
From: Wang Cao <doubleecao@gmail.com>

It appears the initial intention was to print stats for the first
output. Currently all output streams are aggregated for the final stats
which is inconsistent with the "size" reported in print_report.

For example, when two outputs are specified, output 0 has size of 100 kB
and output 1 has size of 50 kB. The output would look like:

frame=  206 fps=3.6 q=0.0 LPSNR=Y:45.57 U:50.04 V:50.07 *:46.62 size=    100kB time=00:00:07.10 bitrate=1362.7kbits/s speed=0.124x
video:140kB audio:79kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.382502%

The "video" reported is larger than the previous line and this is
confusing.

Signed-off-by: Wang Cao <doubleecao@gmail.com>
---
 fftools/ffmpeg.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Wang Cao July 7, 2020, 11:10 p.m. UTC | #1
Friendly ping here. Is there something I need to change for this patch set?
Any comments are welcome. Thank you!
Wang Cao July 18, 2020, 1:30 a.m. UTC | #2
Hi,

I am wondering if this is a change that would make unpredictable impact on
the stats report for ffmpeg. If this is the case, can you take a look at my
next patch in the series? It adds an option to print stats for each output
file when enabled. Thank you!

Best,
Wang
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 2e9448ea2b..07396204b6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1516,6 +1516,7 @@  static int reap_filters(int flush)
 
 static void print_final_stats(int64_t total_size)
 {
+    AVFormatContext *oc;
     uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
     uint64_t subtitle_size = 0;
     uint64_t data_size = 0;
@@ -1523,7 +1524,9 @@  static void print_final_stats(int64_t total_size)
     int i, j;
     int pass1_used = 1;
 
-    for (i = 0; i < nb_output_streams; i++) {
+    oc = output_files[0]->ctx;
+
+    for (i = 0; i < oc->nb_streams; i++) {
         OutputStream *ost = output_streams[i];
         switch (ost->enc_ctx->codec_type) {
             case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break;
@@ -1674,7 +1677,7 @@  static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
     vid = 0;
     av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
     av_bprint_init(&buf_script, 0, AV_BPRINT_SIZE_AUTOMATIC);
-    for (i = 0; i < nb_output_streams; i++) {
+    for (i = 0; i < oc->nb_streams; i++) {
         float q = -1;
         ost = output_streams[i];
         enc = ost->enc_ctx;