From patchwork Mon May 7 13:16:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dixit, Vishwanath" X-Patchwork-Id: 8835 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp2855938jad; Mon, 7 May 2018 06:17:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqcKXSRnj12nCIG8oSDpj5eMK6dWAPLXZ5k6VuBN7bRr2d2W80wF6IRl4wtIh2sRxnlTaoH X-Received: by 10.28.113.220 with SMTP id d89mr789811wmi.26.1525699022876; Mon, 07 May 2018 06:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525699022; cv=none; d=google.com; s=arc-20160816; b=Ogl2XNe3K9S4g8rLiqlrfHM9NTf3RtwPCXKht6rpgnIn3GgJ2fsmvN7vRkSIsjJShX nlv8rxqirwSPB9/omsN1Q2sUwMIBKlERvh6y9ce1/F+DO0AuBhEDUOqSu5rKVsLkh4Hz J74YnTnsEGJQihOLRZ57RotTHuf6AutnTMeKElpSEs99XEkXsKRj2GilgkeX9XLIr/H5 AlcFg+k90lOojxVXDOSh/8SLgQY+O2V1tqv2FF9XR7a9AnctZ8kKZvwN9FGl9nhKooVy trKKGu9T59q1DJ9EgkHYlxOStkfzCZnDjn2ix/OwBqq/9yll1qyl6pXx2jUiG/ZgHt/+ nhyA== 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:feedback-id:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=Yskj1b7GAirsEViDu5wy9KsSxXtL+lLSvf/hV6XtUdw=; b=HDXKqFezlvnLsDA4n6vPL2otlJOuCxXKzR1r+wYW5D3KrdSctf7vr523nWjrdnMZ14 /qtHRNTkq2ifV8gbDdAxnMUPjLxhRyCT7F34j+xHHM+p7LZBtVlQdPnClu/kREaK3k72 rxIINwEmICcPRggOcrkDWEsuMPn2ASDf8iP3SRa+7jr85pDUwD53etezd4g0IiirvLw9 vnGVE+2IYQPG7TK0I3+zSTTfDv4B1fZTodcViJsvqM+SpgekMLkkvb9kpDCeczp9xKW7 hCBqBBKfLY/RxEek1X6Vid6jPc1BWV72CT6hyZ3DhMvOYJ+Et11AAG2AZkmalBQDwpqh SM9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=neOipb+t; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 92-v6si20088475wrb.456.2018.05.07.06.17.02; Mon, 07 May 2018 06:17:02 -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=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=neOipb+t; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6041568A56F; Mon, 7 May 2018 16:16:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a1i318.smtp2go.com (a1i318.smtp2go.com [43.228.185.62]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 95A6E68A4A3 for ; Mon, 7 May 2018 16:16:19 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1525699920; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=SN1VyauPZHZtSnuRFHQa5tH3XrVg4Yhx9ek1m64I7sg=; b=neOipb+t 0n0iMutN1a+9L7++ywvjTzHQ1emPZwF+kgVTXyenHbh0fdQiGORi6Zi86qjkt4rDeuJASvDWr3yeQ NXFlraVX/bxsZktue0JUEJ6yv7lq/gfMsjRtFW9fCNEi/WFsjCRaslvs+mr22R7EekeLouPxLMB3F s3sw+++lq74Cm0G4UYaczQQqYCzbI2i5mIAjLHVUM0v9aVvVYhoTyQMQd+0vnIHGmz9zwIKU8lOsG fkQYzRGxRe+cePLlpwfMLamtFROk2ln6/3r2HxfCtbY824MBNDF/K06mOI+RK3znp4AyRCBSWuS6s GdsWDFctU+8vd5pxDEZ/Gn1mPw==; From: vdixit@akamai.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 May 2018 18:46:42 +0530 Message-Id: <1525699002-23983-1-git-send-email-vdixit@akamai.com> X-Mailer: git-send-email 1.9.1 X-Smtpcorp-Track: 1fFg0WRyINkOTP.8UHUpaqkI Feedback-ID: 337386m:337386asVRLGB:337386sM7AKKLHNq:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH 1/1] avfilter/drawtext: present 'hms' formatted 'pts' in 24h format 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: Vishwanath Dixit MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Vishwanath Dixit HMS is formatted as HH:MM:SS.mmm, but, HH part is not limited to 24 hours. For example, the the drawn text may look like this: 243029:20:30.342. To present the timestamp in more readable and user friendly format, this patch provides an additional option to limit the hour part in the range 0-23. Note: Actually the above required format can be obtained with format options 'localtime' and 'gmtime', but, milliseconds part is not supported in those formats. --- doc/filters.texi | 4 ++++ libavfilter/vf_drawtext.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 33e27e1..6e306f1 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8134,6 +8134,10 @@ local time zone time. The second argument is an offset added to the timestamp. +If the format is set to @code{hms}, a third argument @code{24HH} may be +supplied to present the hour part of the formatted timestamp in 24h format +(00-23). + If the format is set to @code{localtime} or @code{gmtime}, a third argument may be supplied: a strftime() format string. By default, @var{YYYY-MM-DD HH:MM:SS} format will be used. diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index e8905a4..3affa73 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -916,6 +916,14 @@ static int func_pts(AVFilterContext *ctx, AVBPrint *bp, sign = '-'; ms = -ms; } + if (argc >= 3) { + if (!strcmp(argv[2], "24HH")) { + ms %= 24 * 60 * 60 * 1000; + } else { + av_log(ctx, AV_LOG_ERROR, "Invalid argument '%s'\n", argv[2]); + return AVERROR(EINVAL); + } + } av_bprintf(bp, "%c%02d:%02d:%02d.%03d", sign, (int)(ms / (60 * 60 * 1000)), (int)(ms / (60 * 1000)) % 60,