[FFmpeg-devel] [PATCH] lavfi/af_volumedetect: print stats in uninit().

Nicolas George nicolas.george at normalesup.org
Wed Oct 17 19:49:19 CEST 2012


If the stats are printed when request_frame on the input
returns EOF, then they are never printed if the filter is
not flushed, in particular when using the -t ffmpeg option.

Fix trac ticket #1727.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavfilter/af_volumedetect.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)


Note: I could have used ".uninit = print_stats" directly but I find that
solution ugly.


diff --git a/libavfilter/af_volumedetect.c b/libavfilter/af_volumedetect.c
index 9bc40f6..cffcb85 100644
--- a/libavfilter/af_volumedetect.c
+++ b/libavfilter/af_volumedetect.c
@@ -129,10 +129,12 @@ static void print_stats(AVFilterContext *ctx)
 static int request_frame(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
-    int ret = ff_request_frame(ctx->inputs[0]);
-    if (ret == AVERROR_EOF)
-        print_stats(ctx);
-    return ret;
+    return ff_request_frame(ctx->inputs[0]);
+}
+
+static void uninit(AVFilterContext *ctx)
+{
+    print_stats(ctx);
 }
 
 AVFilter avfilter_af_volumedetect = {
@@ -141,6 +143,7 @@ AVFilter avfilter_af_volumedetect = {
 
     .priv_size     = sizeof(VolDetectContext),
     .query_formats = query_formats,
+    .uninit        = uninit,
 
     .inputs    = (const AVFilterPad[]) {
         { .name             = "default",
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list