Browse code

cmdutils: add show_demuxers and show_muxers

add -muxers and -demuxers parameters to list the dexmuers and muxers

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Steven Liu authored on 2016/11/04 21:20:25
Showing 3 changed files
... ...
@@ -75,6 +75,12 @@ static FILE *report_file;
75 75
 static int report_file_level = AV_LOG_DEBUG;
76 76
 int hide_banner = 0;
77 77
 
78
+enum show_muxdemuxers {
79
+    SHOW_DEFAULT,
80
+    SHOW_DEMUXERS,
81
+    SHOW_MUXERS,
82
+};
83
+
78 84
 void init_opts(void)
79 85
 {
80 86
     av_dict_set(&sws_dict, "flags", "bicubic", 0);
... ...
@@ -1251,7 +1257,7 @@ static int is_device(const AVClass *avclass)
1251 1251
     return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
1252 1252
 }
1253 1253
 
1254
-static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only)
1254
+static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
1255 1255
 {
1256 1256
     AVInputFormat *ifmt  = NULL;
1257 1257
     AVOutputFormat *ofmt = NULL;
... ...
@@ -1269,29 +1275,33 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
1269 1269
         const char *name      = NULL;
1270 1270
         const char *long_name = NULL;
1271 1271
 
1272
-        while ((ofmt = av_oformat_next(ofmt))) {
1273
-            is_dev = is_device(ofmt->priv_class);
1274
-            if (!is_dev && device_only)
1275
-                continue;
1276
-            if ((!name || strcmp(ofmt->name, name) < 0) &&
1277
-                strcmp(ofmt->name, last_name) > 0) {
1278
-                name      = ofmt->name;
1279
-                long_name = ofmt->long_name;
1280
-                encode    = 1;
1272
+        if (muxdemuxers !=SHOW_DEMUXERS) {
1273
+            while ((ofmt = av_oformat_next(ofmt))) {
1274
+                is_dev = is_device(ofmt->priv_class);
1275
+                if (!is_dev && device_only)
1276
+                    continue;
1277
+                if ((!name || strcmp(ofmt->name, name) < 0) &&
1278
+                    strcmp(ofmt->name, last_name) > 0) {
1279
+                    name      = ofmt->name;
1280
+                    long_name = ofmt->long_name;
1281
+                    encode    = 1;
1282
+                }
1281 1283
             }
1282 1284
         }
1283
-        while ((ifmt = av_iformat_next(ifmt))) {
1284
-            is_dev = is_device(ifmt->priv_class);
1285
-            if (!is_dev && device_only)
1286
-                continue;
1287
-            if ((!name || strcmp(ifmt->name, name) < 0) &&
1288
-                strcmp(ifmt->name, last_name) > 0) {
1289
-                name      = ifmt->name;
1290
-                long_name = ifmt->long_name;
1291
-                encode    = 0;
1285
+        if (muxdemuxers != SHOW_MUXERS) {
1286
+            while ((ifmt = av_iformat_next(ifmt))) {
1287
+                is_dev = is_device(ifmt->priv_class);
1288
+                if (!is_dev && device_only)
1289
+                    continue;
1290
+                if ((!name || strcmp(ifmt->name, name) < 0) &&
1291
+                    strcmp(ifmt->name, last_name) > 0) {
1292
+                    name      = ifmt->name;
1293
+                    long_name = ifmt->long_name;
1294
+                    encode    = 0;
1295
+                }
1296
+                if (name && strcmp(ifmt->name, name) == 0)
1297
+                    decode = 1;
1292 1298
             }
1293
-            if (name && strcmp(ifmt->name, name) == 0)
1294
-                decode = 1;
1295 1299
         }
1296 1300
         if (!name)
1297 1301
             break;
... ...
@@ -1308,12 +1318,22 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
1308 1308
 
1309 1309
 int show_formats(void *optctx, const char *opt, const char *arg)
1310 1310
 {
1311
-    return show_formats_devices(optctx, opt, arg, 0);
1311
+    return show_formats_devices(optctx, opt, arg, 0, SHOW_DEFAULT);
1312
+}
1313
+
1314
+int show_muxers(void *optctx, const char *opt, const char *arg)
1315
+{
1316
+    return show_formats_devices(optctx, opt, arg, 0, SHOW_MUXERS);
1317
+}
1318
+
1319
+int show_demuxers(void *optctx, const char *opt, const char *arg)
1320
+{
1321
+    return show_formats_devices(optctx, opt, arg, 0, SHOW_DEMUXERS);
1312 1322
 }
1313 1323
 
1314 1324
 int show_devices(void *optctx, const char *opt, const char *arg)
1315 1325
 {
1316
-    return show_formats_devices(optctx, opt, arg, 1);
1326
+    return show_formats_devices(optctx, opt, arg, 1, SHOW_DEFAULT);
1317 1327
 }
1318 1328
 
1319 1329
 #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \
... ...
@@ -442,6 +442,20 @@ int show_license(void *optctx, const char *opt, const char *arg);
442 442
 int show_formats(void *optctx, const char *opt, const char *arg);
443 443
 
444 444
 /**
445
+ * Print a listing containing all the muxers supported by the
446
+ * program (including devices).
447
+ * This option processing function does not utilize the arguments.
448
+ */
449
+int show_muxers(void *optctx, const char *opt, const char *arg);
450
+
451
+/**
452
+ * Print a listing containing all the demuxer supported by the
453
+ * program (including devices).
454
+ * This option processing function does not utilize the arguments.
455
+ */
456
+int show_demuxers(void *optctx, const char *opt, const char *arg);
457
+
458
+/**
445 459
  * Print a listing containing all the devices supported by the
446 460
  * program.
447 461
  * This option processing function does not utilize the arguments.
... ...
@@ -6,6 +6,8 @@
6 6
     { "version"    , OPT_EXIT, {.func_arg = show_version},      "show version" },
7 7
     { "buildconf"  , OPT_EXIT, {.func_arg = show_buildconf},    "show build configuration" },
8 8
     { "formats"    , OPT_EXIT, {.func_arg = show_formats  },    "show available formats" },
9
+    { "muxers"     , OPT_EXIT, {.func_arg = show_muxers   },    "show available muxers" },
10
+    { "demuxers"   , OPT_EXIT, {.func_arg = show_demuxers },    "show available demuxers" },
9 11
     { "devices"    , OPT_EXIT, {.func_arg = show_devices  },    "show available devices" },
10 12
     { "codecs"     , OPT_EXIT, {.func_arg = show_codecs   },    "show available codecs" },
11 13
     { "decoders"   , OPT_EXIT, {.func_arg = show_decoders },    "show available decoders" },