[Ffmpeg-devel] libavcodec help

Antoine Cellerier dionoea
Tue Nov 1 19:41:25 CET 2005


This patch changes the libavcodec help output in ffmpeg from :
-bit_rate          E.VA.
-bit_rate_tolerance E.V..
-flags             EDVA.
-mv4               E.V.. use four motion vector by macroblock (mpeg4)
(...)

to :
-bit_rate <int>       E.VA.
-bit_rate_tolerance <int> E.V..
-flags <flags>        EDVA.
-mv4                  E.V.. use four motion vector by macroblock (mpeg4)
(...)

can be helpfull if you don't have a clue about what an option is
supposed to have as an argument. 

-- 
Antoine Cellerier
dionoea
-------------- next part --------------
Index: libavcodec/opt.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/opt.c,v
retrieving revision 1.9
diff -u -r1.9 opt.c
--- libavcodec/opt.c	20 Sep 2005 12:57:20 -0000	1.9
+++ libavcodec/opt.c	1 Nov 2005 18:38:25 -0000
@@ -254,16 +254,45 @@
     av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
 
     while((opt= av_next_option(obj, opt))){
+        char *str = NULL;
         if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM)))
             continue;
-            
-        av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name);
+
+        switch( opt->type )
+        {
+            case FF_OPT_TYPE_FLAGS:
+                asprintf( &str, "%s <flags>", opt->name );
+                break;
+            case FF_OPT_TYPE_INT:
+                asprintf( &str, "%s <int>", opt->name );
+                break;
+            case FF_OPT_TYPE_INT64:
+                asprintf( &str, "%s <int64>", opt->name );
+                break;
+            case FF_OPT_TYPE_DOUBLE:
+                asprintf( &str, "%s <double>", opt->name );
+                break;
+            case FF_OPT_TYPE_FLOAT:
+                asprintf( &str, "%s <float>", opt->name );
+                break;
+            case FF_OPT_TYPE_STRING:
+                asprintf( &str, "%s <string>", opt->name );
+                break;
+            case FF_OPT_TYPE_RATIONAL:
+                asprintf( &str, "%s <rational>", opt->name );
+                break;
+            case FF_OPT_TYPE_CONST:
+            default:
+                asprintf( &str, "%s", opt->name );
+                break;
+        }
+        av_log(av_log_obj, AV_LOG_INFO, "-%-20s ", str);
+        av_free( str );
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM   ) ? 'V' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM   ) ? 'A' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
-        
         if(opt->help)
             av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
         av_log(av_log_obj, AV_LOG_INFO, "\n");



More information about the ffmpeg-devel mailing list