diff mbox series

[FFmpeg-devel,2/2] ftools/opt_common: Print filter input/output formats in help output

Message ID c99d278881ffe1bfd72f1784ff58ced6d3518d22.1665494271.git.ffmpegagent@gmail.com
State New
Headers show
Series Print filter input/output formats in help output | expand

Checks

Context Check Description
andriy/make_fate_x86 success Make fate finished
andriy/make_x86 warning New warnings during build

Commit Message

Aman Karmani Oct. 11, 2022, 1:17 p.m. UTC
From: softworkz <softworkz@hotmail.com>

Exmaple command: ffmpeg -h filters=overlay

Output:

Filter overlay
  Overlay a video source on top of the input.
    slice threading supported
    Inputs:
       #0: main (video), Formats: Dynamic, Default: [yuv420p, yuvj420p,
                                                  yuva420p, nv12, nv21]
       #1: overlay (video), Formats: Dynamic, Default: [yuva420p]
    Outputs:
       #0: default (video), Formats: Dynamic, Default: [yuv420p, yuvj420p,
                                                     yuva420p, nv12, nv21]

overlay AVOptions:
    [...]

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 fftools/opt_common.c | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index 8a06df82df..cb9de897a3 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -504,7 +504,8 @@  static void show_help_filter(const char *name)
 {
 #if CONFIG_AVFILTER
     const AVFilter *f = avfilter_get_by_name(name);
-    int i, count;
+    AVBPrint bp;
+    int i, count, ret;
 
     if (!name) {
         av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n");
@@ -514,40 +515,54 @@  static void show_help_filter(const char *name)
         return;
     }
 
-    printf("Filter %s\n", f->name);
+    av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
+    av_log_set_callback(NULL);
+
+    av_bprintf(&bp, "Filter %s\n", f->name);
     if (f->description)
-        printf("  %s\n", f->description);
+        av_bprintf(&bp, "  %s\n", f->description);
 
     if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
-        printf("    slice threading supported\n");
+        av_bprintf(&bp, "    slice threading supported\n");
 
-    printf("    Inputs:\n");
+    av_bprintf(&bp, "    Inputs:\n");
     count = avfilter_filter_pad_count(f, 0);
     for (i = 0; i < count; i++) {
-        printf("       #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
+        av_bprintf(&bp, "       #%d: %s (%s), Formats: ", i, avfilter_pad_get_name(f->inputs, i),
                av_get_media_type_string(avfilter_pad_get_type(f->inputs, i)));
+
+        avfilter_print_config_formats(&bp, f, 0, i);
+        av_bprintf(&bp, "\n");
     }
     if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
-        printf("        dynamic (depending on the options)\n");
+        av_bprintf(&bp, "        dynamic (depending on the options)\n");
     else if (!count)
-        printf("        none (source filter)\n");
+        av_bprintf(&bp, "        none (source filter)\n");
 
-    printf("    Outputs:\n");
+    av_bprintf(&bp, "    Outputs:\n");
     count = avfilter_filter_pad_count(f, 1);
     for (i = 0; i < count; i++) {
-        printf("       #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i),
+        av_bprintf(&bp, "       #%d: %s (%s), Formats: ", i, avfilter_pad_get_name(f->outputs, i),
                av_get_media_type_string(avfilter_pad_get_type(f->outputs, i)));
+ 
+        avfilter_print_config_formats(&bp, f, 1, i);
+        av_bprintf(&bp, "\n");
     }
     if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
-        printf("        dynamic (depending on the options)\n");
+        av_bprintf(&bp, "        dynamic (depending on the options)\n");
     else if (!count)
-        printf("        none (sink filter)\n");
+        av_bprintf(&bp, "        none (sink filter)\n");
+
+    av_log_set_callback(log_callback_help);
+    printf("%s\n", bp.str);
 
     if (f->priv_class)
         show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM |
                                           AV_OPT_FLAG_AUDIO_PARAM);
     if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
         printf("This filter has support for timeline through the 'enable' option.\n");
+
+    av_bprint_finalize(&bp, NULL);
 #else
     av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; "
            "can not to satisfy request\n");