ffmpeg: add -devices param

FFmpeg mix devices and file formats when -formats option is used.
This commit adds a -devices param to list devices only.

Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/72/merge
Lukasz Marek 11 years ago committed by Michael Niedermayer
parent bbc10a1aa5
commit 8518da23f5
  1. 35
      cmdutils.c
  2. 9
      cmdutils.h
  3. 1
      cmdutils_common_opts.h
  4. 4
      doc/indevs.texi
  5. 4
      doc/outdevs.texi

@ -1193,16 +1193,29 @@ int show_license(void *optctx, const char *opt, const char *arg)
return 0; return 0;
} }
int show_formats(void *optctx, const char *opt, const char *arg) static int is_device(const AVClass *avclass)
{
if (!avclass)
return 0;
return avclass->category == AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ||
avclass->category == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ||
avclass->category == AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ||
avclass->category == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ||
avclass->category == AV_CLASS_CATEGORY_DEVICE_OUTPUT ||
avclass->category == AV_CLASS_CATEGORY_DEVICE_INPUT;
}
static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only)
{ {
AVInputFormat *ifmt = NULL; AVInputFormat *ifmt = NULL;
AVOutputFormat *ofmt = NULL; AVOutputFormat *ofmt = NULL;
const char *last_name; const char *last_name;
int is_dev;
printf("File formats:\n" printf("%s\n"
" D. = Demuxing supported\n" " D. = Demuxing supported\n"
" .E = Muxing supported\n" " .E = Muxing supported\n"
" --\n"); " --\n", device_only ? "Devices:" : "File formats:");
last_name = "000"; last_name = "000";
for (;;) { for (;;) {
int decode = 0; int decode = 0;
@ -1211,6 +1224,9 @@ int show_formats(void *optctx, const char *opt, const char *arg)
const char *long_name = NULL; const char *long_name = NULL;
while ((ofmt = av_oformat_next(ofmt))) { while ((ofmt = av_oformat_next(ofmt))) {
is_dev = is_device(ofmt->priv_class);
if (!is_dev && device_only)
continue;
if ((name == NULL || strcmp(ofmt->name, name) < 0) && if ((name == NULL || strcmp(ofmt->name, name) < 0) &&
strcmp(ofmt->name, last_name) > 0) { strcmp(ofmt->name, last_name) > 0) {
name = ofmt->name; name = ofmt->name;
@ -1219,6 +1235,9 @@ int show_formats(void *optctx, const char *opt, const char *arg)
} }
} }
while ((ifmt = av_iformat_next(ifmt))) { while ((ifmt = av_iformat_next(ifmt))) {
is_dev = is_device(ifmt->priv_class);
if (!is_dev && device_only)
continue;
if ((name == NULL || strcmp(ifmt->name, name) < 0) && if ((name == NULL || strcmp(ifmt->name, name) < 0) &&
strcmp(ifmt->name, last_name) > 0) { strcmp(ifmt->name, last_name) > 0) {
name = ifmt->name; name = ifmt->name;
@ -1241,6 +1260,16 @@ int show_formats(void *optctx, const char *opt, const char *arg)
return 0; return 0;
} }
int show_formats(void *optctx, const char *opt, const char *arg)
{
return show_formats_devices(optctx, opt, arg, 0);
}
int show_devices(void *optctx, const char *opt, const char *arg)
{
return show_formats_devices(optctx, opt, arg, 1);
}
#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \
if (codec->field) { \ if (codec->field) { \
const type *p = codec->field; \ const type *p = codec->field; \

@ -431,11 +431,18 @@ int show_license(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the formats supported by the * Print a listing containing all the formats supported by the
* program. * program (including devices).
* This option processing function does not utilize the arguments. * This option processing function does not utilize the arguments.
*/ */
int show_formats(void *optctx, const char *opt, const char *arg); int show_formats(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the devices supported by the
* program.
* This option processing function does not utilize the arguments.
*/
int show_devices(void *optctx, const char *opt, const char *arg);
/** /**
* Print a listing containing all the codecs supported by the * Print a listing containing all the codecs supported by the
* program. * program.

@ -6,6 +6,7 @@
{ "version" , OPT_EXIT, {.func_arg = show_version}, "show version" }, { "version" , OPT_EXIT, {.func_arg = show_version}, "show version" },
{ "buildconf" , OPT_EXIT, {.func_arg = show_buildconf}, "show build configuration" }, { "buildconf" , OPT_EXIT, {.func_arg = show_buildconf}, "show build configuration" },
{ "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" }, { "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" },
{ "devices" , OPT_EXIT, {.func_arg = show_devices }, "show available devices" },
{ "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" }, { "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" },
{ "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" }, { "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" },
{ "encoders" , OPT_EXIT, {.func_arg = show_encoders }, "show available encoders" }, { "encoders" , OPT_EXIT, {.func_arg = show_encoders }, "show available encoders" },

@ -13,8 +13,8 @@ You can disable all the input devices using the configure option
option "--enable-indev=@var{INDEV}", or you can disable a particular option "--enable-indev=@var{INDEV}", or you can disable a particular
input device using the option "--disable-indev=@var{INDEV}". input device using the option "--disable-indev=@var{INDEV}".
The option "-formats" of the ff* tools will display the list of The option "-devices" of the ff* tools will display the list of
supported input devices (amongst the demuxers). supported input devices.
A description of the currently available input devices follows. A description of the currently available input devices follows.

@ -13,8 +13,8 @@ You can disable all the output devices using the configure option
option "--enable-outdev=@var{OUTDEV}", or you can disable a particular option "--enable-outdev=@var{OUTDEV}", or you can disable a particular
input device using the option "--disable-outdev=@var{OUTDEV}". input device using the option "--disable-outdev=@var{OUTDEV}".
The option "-formats" of the ff* tools will display the list of The option "-devices" of the ff* tools will display the list of
enabled output devices (amongst the muxers). enabled output devices.
A description of the currently available output devices follows. A description of the currently available output devices follows.

Loading…
Cancel
Save