From patchwork Tue Jan 7 12:14:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 17232 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 886CE44ADC0 for ; Tue, 7 Jan 2020 14:15:08 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5F27A68A588; Tue, 7 Jan 2020 14:15:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 71E786880E8 for ; Tue, 7 Jan 2020 14:15:02 +0200 (EET) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 47sWXj6TyMzKmZW for ; Tue, 7 Jan 2020 13:15:01 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id oOIdt9yAsTet for ; Tue, 7 Jan 2020 13:14:58 +0100 (CET) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Tue, 7 Jan 2020 17:44:41 +0530 Message-Id: <20200107121441.8370-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/f_metadata: allow direct flushing when printing to file 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" Useful for monitoring sparse data in realtime --- doc/filters.texi | 3 +++ libavfilter/f_metadata.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index fc2d198077..e682ba62bb 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -22711,6 +22711,9 @@ plain filename any writable url can be specified. Filename ``-'' is a shorthand for standard output. If @code{file} option is not set, output is written to the log with AV_LOG_INFO loglevel. +@item direct +Reduces buffering in print mode when output is written to a URL set using @var{file}. + @end table @subsection Examples diff --git a/libavfilter/f_metadata.c b/libavfilter/f_metadata.c index 3bf4bb17f5..bf298e9d39 100644 --- a/libavfilter/f_metadata.c +++ b/libavfilter/f_metadata.c @@ -88,6 +88,8 @@ typedef struct MetadataContext { int (*compare)(struct MetadataContext *s, const char *value1, const char *value2); void (*print)(AVFilterContext *ctx, const char *msg, ...) av_printf_format(2, 3); + + int direct; // reduces buffering when printing to user-supplied URL } MetadataContext; #define OFFSET(x) offsetof(MetadataContext, x) @@ -111,6 +113,7 @@ static const AVOption filt_name##_options[] = { \ { "ends_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_ENDS_WITH }, 0, 0, FLAGS, "function" }, \ { "expr", "set expression for expr function", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \ { "file", "set file where to print metadata information", OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \ + { "direct", "reduce buffering when printing to user-set file or pipe", OFFSET(direct), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, \ { NULL } \ } @@ -274,6 +277,9 @@ static av_cold int init(AVFilterContext *ctx) s->file_str, buf); return ret; } + + if (s->direct) + s->avio_context->direct = AVIO_FLAG_DIRECT; } return 0;