diff mbox series

[FFmpeg-devel] fftools/opt_common.c: Display muxer/demuxer flags in help screen.

Message ID 20220422001139.39280-1-toots@rastageeks.org
State New
Headers show
Series [FFmpeg-devel] fftools/opt_common.c: Display muxer/demuxer flags in help screen. | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_fate_aarch64_jetson fail Make fate failed
andriy/make_aarch64_jetson warning New warnings during build
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Romain Beauxis April 22, 2022, 12:11 a.m. UTC
From: Romain Beauxis <toots@rastageeks.org>

---
Showing muxer/demuxer flags can be very useful to quickly glance at specific
properties, in particular global headers flags. This patch adds a display of
these flags in the -h muxer=... and -h demuxer=... calls.

 fftools/opt_common.c | 78 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
diff mbox series

Patch

diff --git a/fftools/opt_common.c b/fftools/opt_common.c
index c303db4d09..c0daf0840a 100644
--- a/fftools/opt_common.c
+++ b/fftools/opt_common.c
@@ -424,6 +424,80 @@  static void show_help_codec(const char *name, int encoder)
     }
 }
 
+const int fmt_flags[] = {
+  AVFMT_NOFILE,
+  AVFMT_NEEDNUMBER,
+  AVFMT_EXPERIMENTAL,
+  AVFMT_SHOW_IDS,
+  AVFMT_GLOBALHEADER,
+  AVFMT_NOTIMESTAMPS,
+  AVFMT_GENERIC_INDEX,
+  AVFMT_TS_DISCONT,
+  AVFMT_VARIABLE_FPS,
+  AVFMT_NODIMENSIONS,
+  AVFMT_NOSTREAMS,
+  AVFMT_NOBINSEARCH,
+  AVFMT_NOGENSEARCH,
+  AVFMT_NO_BYTE_SEEK,
+  AVFMT_ALLOW_FLUSH,
+  AVFMT_TS_NONSTRICT,
+  AVFMT_TS_NEGATIVE,
+  AVFMT_SEEK_TO_PTS
+};
+
+const char *fmt_flags_name[] = {
+  "AVFMT_NOFILE",
+  "AVFMT_NEEDNUMBER",
+  "AVFMT_EXPERIMENTAL",
+  "AVFMT_SHOW_IDS",
+  "AVFMT_GLOBALHEADER",
+  "AVFMT_NOTIMESTAMPS",
+  "AVFMT_GENERIC_INDEX",
+  "AVFMT_TS_DISCONT",
+  "AVFMT_VARIABLE_FPS",
+  "AVFMT_NODIMENSIONS",
+  "AVFMT_NOSTREAMS",
+  "AVFMT_NOBINSEARCH",
+  "AVFMT_NOGENSEARCH",
+  "AVFMT_NO_BYTE_SEEK",
+  "AVFMT_ALLOW_FLUSH",
+  "AVFMT_TS_NONSTRICT",
+  "AVFMT_TS_NEGATIVE",
+  "AVFMT_SEEK_TO_PTS"
+};
+
+const char *fmt_flags_help[] = {
+  "Demuxer will use avio_open, no opened file should be provided by the caller.",
+  "Needs 'd' in filename.",
+  "The muxer/demuxer is experimental and should be used with caution.",
+  "Show format stream IDs numbers.",
+  "Format wants global header.",
+  "Format does not need / have any timestamps.",
+  "Use generic index building code.",
+  "Format allows timestamp discontinuities.",
+  "Format allows variable fps.",
+  "Format does not need width/height.",
+  "Format does not require any streams.",
+  "Format does not allow to fall back on binary search via read_timestamp.",
+  "Format does not allow to fall back on generic search.",
+  "Format does not allow seeking by bytes.",
+  "Format allows flushing.",
+  "Format does not require strictly increasing timestamps, but they must still be monotonic.",
+  "Format allows muxing negative timestamps.",
+  "Seeking is based on PTS."
+};
+
+static void show_help_fmt_flags(int flags) {
+    int i;
+
+    printf("flags:\n");
+
+    for (i = 0; i < sizeof(fmt_flags) / sizeof(fmt_flags[0]); i++) {
+        if (flags & fmt_flags[i])
+            printf("    %s: %s\n", fmt_flags_name[i], fmt_flags_help[i]);
+    }
+}
+
 static void show_help_demuxer(const char *name)
 {
     const AVInputFormat *fmt = av_find_input_format(name);
@@ -438,6 +512,8 @@  static void show_help_demuxer(const char *name)
     if (fmt->extensions)
         printf("    Common extensions: %s.\n", fmt->extensions);
 
+    show_help_fmt_flags(fmt->flags);
+
     if (fmt->priv_class)
         show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM);
 }
@@ -489,6 +565,8 @@  static void show_help_muxer(const char *name)
         printf("    Default subtitle codec: %s.\n", desc->name);
     }
 
+    show_help_fmt_flags(fmt->flags);
+
     if (fmt->priv_class)
         show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM);
 }