Skip to content

Commit 16588e7

Browse files
committed
ftools/opt_common: Print filter input/output formats in help output
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 <[email protected]>
1 parent c9496ca commit 16588e7

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

fftools/opt_common.c

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ static void show_help_filter(const char *name)
504504
{
505505
#if CONFIG_AVFILTER
506506
const AVFilter *f = avfilter_get_by_name(name);
507-
int i, count;
507+
AVBPrint bp;
508+
int i, count, ret;
508509

509510
if (!name) {
510511
av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n");
@@ -514,40 +515,54 @@ static void show_help_filter(const char *name)
514515
return;
515516
}
516517

517-
printf("Filter %s\n", f->name);
518+
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
519+
av_log_set_callback(NULL);
520+
521+
av_bprintf(&bp, "Filter %s\n", f->name);
518522
if (f->description)
519-
printf(" %s\n", f->description);
523+
av_bprintf(&bp, " %s\n", f->description);
520524

521525
if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
522-
printf(" slice threading supported\n");
526+
av_bprintf(&bp, " slice threading supported\n");
523527

524-
printf(" Inputs:\n");
528+
av_bprintf(&bp, " Inputs:\n");
525529
count = avfilter_filter_pad_count(f, 0);
526530
for (i = 0; i < count; i++) {
527-
printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
531+
av_bprintf(&bp, " #%d: %s (%s), Formats: ", i, avfilter_pad_get_name(f->inputs, i),
528532
av_get_media_type_string(avfilter_pad_get_type(f->inputs, i)));
533+
534+
avfilter_print_config_formats(&bp, f, 0, i);
535+
av_bprintf(&bp, "\n");
529536
}
530537
if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
531-
printf(" dynamic (depending on the options)\n");
538+
av_bprintf(&bp, " dynamic (depending on the options)\n");
532539
else if (!count)
533-
printf(" none (source filter)\n");
540+
av_bprintf(&bp, " none (source filter)\n");
534541

535-
printf(" Outputs:\n");
542+
av_bprintf(&bp, " Outputs:\n");
536543
count = avfilter_filter_pad_count(f, 1);
537544
for (i = 0; i < count; i++) {
538-
printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i),
545+
av_bprintf(&bp, " #%d: %s (%s), Formats: ", i, avfilter_pad_get_name(f->outputs, i),
539546
av_get_media_type_string(avfilter_pad_get_type(f->outputs, i)));
547+
548+
avfilter_print_config_formats(&bp, f, 1, i);
549+
av_bprintf(&bp, "\n");
540550
}
541551
if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
542-
printf(" dynamic (depending on the options)\n");
552+
av_bprintf(&bp, " dynamic (depending on the options)\n");
543553
else if (!count)
544-
printf(" none (sink filter)\n");
554+
av_bprintf(&bp, " none (sink filter)\n");
555+
556+
av_log_set_callback(log_callback_help);
557+
printf("%s\n", bp.str);
545558

546559
if (f->priv_class)
547560
show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM |
548561
AV_OPT_FLAG_AUDIO_PARAM);
549562
if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
550563
printf("This filter has support for timeline through the 'enable' option.\n");
564+
565+
av_bprint_finalize(&bp, NULL);
551566
#else
552567
av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; "
553568
"can not to satisfy request\n");

0 commit comments

Comments
 (0)