From patchwork Thu Jun 14 12:35:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Cao X-Patchwork-Id: 9408 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp1894189jad; Thu, 14 Jun 2018 06:06:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKINC50RhZZl0QjQ0ZwxMPyP1Z41NNm8PkbfK8MIyngABrPNeG/vl6KNq7subvcLwf85saZw X-Received: by 2002:a1c:b18a:: with SMTP id a132-v6mr1724302wmf.18.1528981588194; Thu, 14 Jun 2018 06:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528981588; cv=none; d=google.com; s=arc-20160816; b=o17RDMLUAq+AQHUAURtxnhGExQGeGwRAdk8kfILvEfXoE6kVkMfHzRiFUPtUCDutjL md7fneoUZ+jVy7xeBCxYuLD59dpLkmAhxQXqmSfY2DKfx6DfsQJvBlQSQT3UjOavziR9 Y4yqUZ7sgcHx3olSyZ9KkdqTem1WkFAwC2f73bJIBkuTsHtVB8Vv+sPjBwKwlnLtIxfQ FKE9WU/1V2J9v4YwQOqM1LiG9hgOupRE00keuiNwRnkVm2pXFAJExry211a2Qv0T+jas KnTwmaCKEhQM9zx38wKB3RRmu403p5h7SaEyJbW/xZ39yNjRYtU35PdRs8o4uGwQDPfA TibA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=oRx0+ODXjsuvhOT9gxH2eg/sfzj01oFtXYopoLEWCAI=; b=jNWaaZN5heVEhmwRoVt3XdwSBP+DwNtOgJBFePHyP//mFzfEfXqJztJABtL7Jla3Id zrz/bMSeL3wqsBLS8myY0JzFG1x4kcCoWyqsOo3uiOIk8l/epQG/TKC5OwEU4z6+mKxf HjDrvEehOge6p90Rkntm+VuytU0bxeucLMwoMVR9aBoMT9xwqm9GFrqu9v2RnUflXi/1 jALbXA4sI6NRg0DYulmNswYJ8qKuqr/okR5tqyg4wMOk47M2r4O0fYOSin5Rqlj0X5RG dp4/ExsjUEveZsEg+YcaRkEQBQsHVKPhJSPkMFyzYWaC5rudqs98IfdOezBa0aYtZq2s IZ9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=o5BxaCZs; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j8-v6si259997wrh.398.2018.06.14.06.06.27; Thu, 14 Jun 2018 06:06:28 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=o5BxaCZs; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2013D68ABEE; Thu, 14 Jun 2018 16:05:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE08568ABB9 for ; Thu, 14 Jun 2018 16:05:28 +0300 (EEST) Received: by mail-pf0-f196.google.com with SMTP id y8-v6so3215917pfm.10 for ; Thu, 14 Jun 2018 06:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ehbn8MI8pPk1VQl9V2vlixwRRaXyuG8ndPqvV+bKQZs=; b=o5BxaCZsxDp8z85+U1wIHCHDdD+aR5GI6pBGF6HqgXDCFguH9xCKQMxrvTdbzzmGHH VSp72+RdPPFYhj3imZa1Txw6aJ3HIuE4xorUohWNnsPBYWGGcrUOXA0lXWaPFM98fc3j dLHuTePYM6j1h1g9M8VuxsZjUL4rHLBGD+XKaORwPJHlMOmMnhqHwU0QxAq+G7FF9pq5 xewaVlg+FdioJuJoAr22GUYUnYstBXurd4ca29ZiVaGLSJxTJljeZYrwHzEq9oTkXdKO +FACaUMC+nQQbNmGgeebbG2TaLXlUBuVad6Xou+xtAdzjQlJ9awezWPQtQXxU3I0+qxD jVFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ehbn8MI8pPk1VQl9V2vlixwRRaXyuG8ndPqvV+bKQZs=; b=tzJHtvqW7/K6R5pR6yBS/Vr9WrkrsULVmxjsqKI7fZkyXIsHWToOUb/cNkmUpmcCS6 EJ0mlmlBRn4qqwwjtOmZVChN866B/R/oc4NsCB2vwa6Wdf5+9/3ela/9GjGsO597x3G7 eNRh6+8DADr7AcJuT9ePSpxzCoH6KXboLq9qHa1pTqdLGMQef1AHTfazYkPPEV/8gsAW +k6JpiBiTudiOk0Gh+7Xz+RgaUOb9IXSuWuBl6zoVTRJH8nIPZ+FIcdCURICr2YiYnXG byIWUXCCkGBtZA0MVfMg0LtzfQotVynIG3vJ0pPDSgH7UvAAM2iei6/ZN1B6lWo+EsLr NMaQ== X-Gm-Message-State: APt69E373uQJDJHZ9ce2YzMcYfNwDI2NO89KmFo/IIzAwTlCynvZfS1+ rCGJ9x45cNHkKAV9Sf3w7ZFnBjpr X-Received: by 2002:a63:6dc5:: with SMTP id i188-v6mr2143264pgc.391.1528979775234; Thu, 14 Jun 2018 05:36:15 -0700 (PDT) Received: from wangcao1.bej.corp.google.com ([2401:fa00:44:10:97fa:2969:3ac1:d58e]) by smtp.gmail.com with ESMTPSA id s14-v6sm7716579pfh.116.2018.06.14.05.36.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 05:36:14 -0700 (PDT) From: Wang Cao X-Google-Original-From: Wang Cao To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Jun 2018 20:35:48 +0800 Message-Id: <20180614123548.251107-1-wangcao@google.com> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a-goog In-Reply-To: <20180525143728.GQ4859@michaelspb> References: <20180525143728.GQ4859@michaelspb> Subject: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream - Make ffmpeg to output stats for each video/audio streams and each ouptut file ffmpeg output log in print_report. The report of video/audio sizes is clear now as previously all output video/audio sizes were combined to report and it is unclear such stats is for one output files or aggregates for all output files. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Wang Cao MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Wang Cao --- fftools/ffmpeg.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index d4ac6903cc..1eaf344552 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1530,17 +1530,27 @@ static int reap_filters(int flush) return 0; } -static void print_final_stats(int64_t total_size) +static void print_final_stats() { uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0; uint64_t subtitle_size = 0; uint64_t data_size = 0; + int64_t total_size; float percent = -1.0; int i, j; int pass1_used = 1; + AVFormatContext *oc; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; + if (i > 0 && ost->file_index != output_streams[i-1]->file_index) { + video_size = 0; + audio_size = 0; + extra_size = 0; + other_size = 0; + subtitle_size = 0; + data_size = 0; + } switch (ost->enc_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break; case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break; @@ -1552,7 +1562,13 @@ static void print_final_stats(int64_t total_size) if ( (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) != AV_CODEC_FLAG_PASS1) pass1_used = 0; - } + + // Print stats for each output file. + if (i == nb_output_streams-1 || ost->file_index != output_streams[i+1]->file_index) { + oc = output_files[ost->file_index]->ctx; + total_size = avio_size(oc->pb); + if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too + total_size = avio_tell(oc->pb); if (data_size && total_size>0 && total_size >= data_size) percent = 100.0 * (total_size - data_size) / data_size; @@ -1568,6 +1584,8 @@ static void print_final_stats(int64_t total_size) else av_log(NULL, AV_LOG_INFO, "unknown"); av_log(NULL, AV_LOG_INFO, "\n"); + } + } /* print verbose per-stream stats */ for (i = 0; i < nb_input_files; i++) { @@ -1680,13 +1698,6 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti t = (cur_time-timer_start) / 1000000.0; - - oc = output_files[0]->ctx; - - total_size = avio_size(oc->pb); - if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too - total_size = avio_tell(oc->pb); - vid = 0; av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(&buf_script, 0, 1); @@ -1697,12 +1708,13 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (!ost->stream_copy) q = ost->quality / (float) FF_QP2LAMBDA; - if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + if (is_last_report && vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { av_bprintf(&buf, "q=%2.1f ", q); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", ost->file_index, ost->index, q); } - if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + if (is_last_report || !is_last_report && !vid) { + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { float fps; frame_number = ost->frame_number; @@ -1761,7 +1773,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti ost->st->time_base, AV_TIME_BASE_Q)); if (is_last_report) nb_frames_drop += ost->last_dropped; - } + total_size = ost->data_size; secs = FFABS(pts) / AV_TIME_BASE; us = FFABS(pts) % AV_TIME_BASE; @@ -1815,8 +1827,13 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti av_bprintf(&buf_script, "speed=%4.3gx\n", speed); } + if (is_last_report) + av_bprintf(&buf, "\n"); + } + } + if (print_stats || is_last_report) { - const char end = is_last_report ? '\n' : '\r'; + const char end = '\r'; if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) { fprintf(stderr, "%s %c", buf.str, end); } else @@ -1841,7 +1858,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti } if (is_last_report) - print_final_stats(total_size); + print_final_stats(); } static void ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par)