[FFmpeg-cvslog] avconv: refactor help printing.

Anton Khirnov git at videolan.org
Mon Aug 20 17:41:35 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Aug 14 08:56:32 2012 +0200| [6e3857fa8cd620d528fb73fe5f7f692db780c4df] | committer: Anton Khirnov

avconv: refactor help printing.

By default don't dump every single option on the user, but print only
the basic options.

Add -h long/full to print more options.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e3857fa8cd620d528fb73fe5f7f692db780c4df
---

 avconv_opt.c |   46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/avconv_opt.c b/avconv_opt.c
index 2bcce3b..7d4922c 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1791,30 +1791,56 @@ static int opt_filter_complex(const char *opt, const char *arg)
 
 void show_help_default(const char *opt, const char *arg)
 {
-    int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
+    int show_advanced = 0, show_avoptions = 0;
+
+    if (opt) {
+        if (!strcmp(opt, "long"))
+            show_advanced = 1;
+        else if (!strcmp(opt, "full"))
+            show_advanced = show_avoptions = 1;
+        else
+            av_log(NULL, AV_LOG_ERROR, "Unknown help option '%s'.\n", opt);
+    }
 
     show_usage();
+
+    printf("Getting help:\n"
+           "    -h      -- print basic options\n"
+           "    -h long -- print more options\n"
+           "    -h full -- print all options (including all format and codec specific options, very long)\n"
+           "    See man %s for detailed description of the options.\n"
+           "\n", program_name);
+
     show_help_options(options, "Print help / information / capabilities:",
                       OPT_EXIT, 0);
     show_help_options(options, "Main options:",
                       0, OPT_EXPERT | OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE |
                       OPT_EXIT);
-    show_help_options(options, "Advanced options:",
-                      OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
+    if (show_advanced)
+        show_help_options(options, "Advanced options:",
+                          OPT_EXPERT, OPT_AUDIO | OPT_VIDEO | OPT_SUBTITLE);
+
     show_help_options(options, "Video options:",
                       OPT_VIDEO, OPT_EXPERT | OPT_AUDIO);
-    show_help_options(options, "Advanced Video options:",
-                      OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
+    if (show_advanced)
+        show_help_options(options, "Advanced Video options:",
+                          OPT_EXPERT | OPT_VIDEO, OPT_AUDIO);
+
     show_help_options(options, "Audio options:",
                       OPT_AUDIO, OPT_EXPERT | OPT_VIDEO);
-    show_help_options(options, "Advanced Audio options:",
-                      OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
+    if (show_advanced)
+        show_help_options(options, "Advanced Audio options:",
+                          OPT_EXPERT | OPT_AUDIO, OPT_VIDEO);
     show_help_options(options, "Subtitle options:",
                       OPT_SUBTITLE, 0);
     printf("\n");
-    show_help_children(avcodec_get_class(), flags);
-    show_help_children(avformat_get_class(), flags);
-    show_help_children(sws_get_class(), flags);
+
+    if (show_avoptions) {
+        int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
+        show_help_children(avcodec_get_class(), flags);
+        show_help_children(avformat_get_class(), flags);
+        show_help_children(sws_get_class(), flags);
+    }
 }
 
 void show_usage(void)



More information about the ffmpeg-cvslog mailing list