From patchwork Wed Feb 28 08:47:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Rapp X-Patchwork-Id: 7764 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.181.170 with SMTP id m39csp3518968jaj; Wed, 28 Feb 2018 00:47:39 -0800 (PST) X-Google-Smtp-Source: AH8x224NTWVPiLrXBk+JMG7jZOsLjAi2W4kVdkujUBOlWJilD6K1qw+09tlXO56zvNO2q/7QN/45 X-Received: by 10.223.147.36 with SMTP id 33mr13994807wro.133.1519807659401; Wed, 28 Feb 2018 00:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519807659; cv=none; d=google.com; s=arc-20160816; b=zTAzUZI/W5dBi8kkuPA1g88iMLU6BIYJFQfWkcXM8xNOE93XNR8yn5zylODeUtL131 jcqwVGOxtSTbDlNEewcGtTtBBrLJt5atwYmKoeG4KYmS1L94g0Lv3Pe6h29R5AgXt0R+ 5SZugTrJIoNvBjmshMUiaxQAWror8QDJ/BA2aUWjTlG4NDdRhnlecHPmAG3kuzEzcIEo zLgGTxOuka+oGHxjmadDjylR5J5LYXG6leu2CoSkN2xIrEuUChscT5MTLGsqUNoYHLQh PZTZbNY+UISJUSxFa97yiMgSWBHsIJgR9rC282axZfhUyo+6f4InPYPC6MEme+KLkPZz JQjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:to:from:delivered-to :arc-authentication-results; bh=fiK/Ac9IpXXijPB1n4KMDI3rt4UVjHqVRJmc4iDKLXQ=; b=oWydq4VZbw8fu6rAgQjpxcShPsFKWIFoNNtwXTifXtDBgAl1kWB6g6wToKT5o92c5r r7BTzbr50vr5iL4fZ6eihyOaFbc0LRnEFdBrmg08mzVMnAu/EP5TJV/7dDV2NC1mCwyD V0bjAiTbF9CUQ8MkY88MFlzasre4W7TQSl1sSsm1XAbE+VcBChDqvPtwboRd7l8oLxpX veLYm081/9utEhmOwVmN3ri0PJYreEPj12C4jdzRTb49AfIp+yxX2m7GhXQS8wgZKCD9 H2pKC1GPmoC5Qbo70bai9NV7e//4KBXIlBRoMyzU5Sbhb9yRhtCV3t0+BOX+cxS2VqDp Tm4Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n35si796636wrn.539.2018.02.28.00.47.38; Wed, 28 Feb 2018 00:47:39 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CF84F68A25F; Wed, 28 Feb 2018 10:47:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx02.mail.netstorage.at (mx02.mail.netstorage.at [89.207.146.155]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB78B689830 for ; Wed, 28 Feb 2018 10:47:24 +0200 (EET) Received: from p1002.netstorage.at (p1002.netstorage.at [89.207.146.186]) by mx02.mail.netstorage.at (Postfix) with ESMTPS id B8EBDA1EDA for ; Wed, 28 Feb 2018 09:47:16 +0100 (CET) Received: from mailix (noaport.de [46.237.252.213]) by p1002.netstorage.at (Postfix) with ESMTPA id 51DE381A14 for ; Wed, 28 Feb 2018 09:47:16 +0100 (CET) Received: from [127.0.0.1] (HSI-KBW-46-237-252-214.hsi.kabel-badenwuerttemberg.de [46.237.252.214]) by mailix with ESMTPSA (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128) ; Wed, 28 Feb 2018 09:47:16 +0100 From: Tobias Rapp To: FFmpeg Development References: <20180226151155.4cffd3fc@debian> <1519661345-16991-1-git-send-email-t.rapp@noa-archive.com> <20180227001208.GI23018@michaelspb> <20180227180306.GM23018@michaelspb> Organization: NOA GmbH Message-ID: <7f1be4b6-f35a-06c5-92b8-6d661a599159@noa-archive.com> Date: Wed, 28 Feb 2018 09:47:15 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180227180306.GM23018@michaelspb> Content-Language: en-US X-PPP-Message-ID: <20180228084716.6356.70520@p1002.netstorage.at> X-PPP-Vhost: noa-archive.com X-NetStorage-MailScanner-Information: Please contact the ISP for more information X-NetStorage-MailScanner-ID: B8EBDA1EDA.AB30B X-NetStorage-MailScanner: Found to be clean X-NetStorage-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (nicht zwischen gespeichert, Wertung=-0.5, benoetigt 6, autolearn=not spam, BAYES_00 -0.50) X-NetStorage-MailScanner-From: t.rapp@noa-archive.com X-Spam-Status: No Subject: Re: [FFmpeg-devel] [PATCH v2 1/2] fftools/ffmpeg: fix progress log message in case pts is not available 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On 27.02.2018 19:03, Michael Niedermayer wrote: > On Tue, Feb 27, 2018 at 08:49:19AM +0100, Tobias Rapp wrote: >> On 27.02.2018 01:12, Michael Niedermayer wrote: >>> On Mon, Feb 26, 2018 at 05:09:04PM +0100, Tobias Rapp wrote: >>>> Move time string formatting into inline function. Also fixes out_time >>>> sign prefix for progress report. >>>> >>>> Signed-off-by: Tobias Rapp >>>> --- >>>> fftools/ffmpeg.c | 48 +++++++++++++++++++++++++++++++----------------- >>>> 1 file changed, 31 insertions(+), 17 deletions(-) >>>> >>> [...] >>>> +{ >>>> + const char *hours_sign; >>>> + int hours, mins; >>>> + double secs; >>>> + >>>> + if (pts == AV_NOPTS_VALUE) { >>>> + snprintf(buf, AV_TS_MAX_STRING_SIZE, "N/A"); >>>> + } else { >>>> + hours_sign = (pts < 0) ? "-" : ""; >>>> + secs = (double)FFABS(pts) / AV_TIME_BASE; >>>> + mins = (int)secs / 60; >>>> + secs = secs - mins * 60; >>>> + hours = mins / 60; >>>> + mins %= 60; >>> >>> This is not the same code, also with double it can produce inexact >>> results and results differing between platforms >> >> I changed secs to double to handle the cases with different number of >> sub-second digits more easily. Would it be OK to output two digits after the >> decimal point in both cases? The progress report contains the precise >> out_time_ms value anyway. > > iam not sure iam guessing correctly what you mean by "both cases" > you mean if its unneeded as in .00 ? > I guess that would be ok There are two places within print_report() that output hour/minute/seconds-formatted time. One is using HH:MM:SS.ZZ format and the other one is using HH:MM:SS.ZZZZZZ format. Would it be OK to output HH:MM:SS.ZZ (two digits after the decimal separator) in both places like in the attached patch version? Regards, Tobias From d2141a259d733e9ff8e76f0e33b3e2e449adde14 Mon Sep 17 00:00:00 2001 From: Tobias Rapp Date: Mon, 26 Feb 2018 16:58:24 +0100 Subject: [PATCH v3] fftools/ffmpeg: fix progress log message in case pts is not available Move time string formatting into inline function. Also fixes out_time sign prefix for progress report. Signed-off-by: Tobias Rapp --- fftools/ffmpeg.c | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 3a45f43..f3598ff 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1518,6 +1518,27 @@ static int reap_filters(int flush) return 0; } +static inline char *pts_to_hms_str(char *buf, size_t buf_size, int64_t pts) +{ + const char *hours_sign; + int hours, mins, secs, usecs; + + if (pts == AV_NOPTS_VALUE) { + snprintf(buf, buf_size, "N/A"); + } else { + hours_sign = (pts < 0) ? "-" : ""; + secs = FFABS(pts) / AV_TIME_BASE; + usecs = FFABS(pts) % AV_TIME_BASE; + mins = secs / 60; + secs %= 60; + hours = mins / 60; + mins %= 60; + snprintf(buf, buf_size, "%s%02d:%02d:%02d.%02d", + hours_sign, hours, mins, secs, (100 * usecs) / AV_TIME_BASE); + } + return buf; +} + static void print_final_stats(int64_t total_size) { uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0; @@ -1649,7 +1670,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti int64_t pts = INT64_MIN + 1; static int64_t last_time = -1; static int qp_histogram[52]; - int hours, mins, secs, us; + char buf_pts[AV_TS_MAX_STRING_SIZE] = {0}; int ret; float t; @@ -1751,25 +1772,15 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti nb_frames_drop += ost->last_dropped; } - secs = FFABS(pts) / AV_TIME_BASE; - us = FFABS(pts) % AV_TIME_BASE; - mins = secs / 60; - secs %= 60; - hours = mins / 60; - mins %= 60; - bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1; speed = t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1; if (total_size < 0) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "size=N/A time="); + "size=N/A "); else snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "size=%8.0fkB time=", total_size / 1024.0); - if (pts < 0) - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "-"); + "size=%8.0fkB ", total_size / 1024.0); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - "%02d:%02d:%02d.%02d ", hours, mins, secs, - (100 * us) / AV_TIME_BASE); + "time=%s ", pts_to_hms_str(buf_pts, sizeof(buf_pts), pts)); if (bitrate < 0) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=N/A"); @@ -1781,9 +1792,12 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n"); else av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size); - av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts); - av_bprintf(&buf_script, "out_time=%02d:%02d:%02d.%06d\n", - hours, mins, secs, us); + if (pts == AV_NOPTS_VALUE) { + av_bprintf(&buf_script, "out_time_ms=N/A\n"); + } else { + av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts); + } + av_bprintf(&buf_script, "out_time=%s\n", pts_to_hms_str(buf_pts, sizeof(buf_pts), pts)); if (nb_frames_dup || nb_frames_drop) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",