53 #include "libavformat/avformat.h" 54 #include "libavfilter/avfilter.h" 55 #include "libavdevice/avdevice.h" 56 #include "libswscale/swscale.h" 57 #include "libswresample/swresample.h" 58 #include "libavutil/attributes.h" 59 #include "libavutil/avassert.h" 60 #include "libavutil/avstring.h" 61 #include "libavutil/bprint.h" 62 #include "libavutil/display.h" 63 #include "libavutil/mathematics.h" 64 #include "libavutil/imgutils.h" 65 #include "libavutil/libm.h" 66 #include "libavutil/parseutils.h" 67 #include "libavutil/pixdesc.h" 68 #include "libavutil/eval.h" 69 #include "libavutil/dict.h" 70 #include "libavutil/opt.h" 71 #include "libavutil/cpu.h" 72 #include "libavutil/ffversion.h" 73 #include "libavutil/version.h" 76 #include "libavformat/network.h" 78 #if HAVE_SYS_RESOURCE_H 80 #include <sys/resource.h> 106 av_dict_set(&
sws_dict,
"flags",
"bicubic", 0);
146 double min,
double max)
150 double d = av_strtod(numstr, &tail);
152 error =
"Expected number for %s but found: %s\n";
153 else if (d < min || d > max)
154 error =
"The value for %s was %s which is not within %f - %f\n";
156 error =
"Expected int64 for %s but found %s\n";
158 error =
"Expected int for %s but found %s\n";
161 av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
170 if (av_parse_time(&us, timestr, is_duration) < 0) {
171 av_log(NULL, AV_LOG_FATAL,
"Invalid %s specification for %s: %s\n",
172 is_duration ?
"duration" :
"date", context, timestr);
179 int rej_flags,
int alt_flags)
188 if (((po->
flags & req_flags) != req_flags) ||
189 (alt_flags && !(po->
flags & alt_flags)) ||
190 (po->
flags & rej_flags))
197 av_strlcpy(buf, po->
name,
sizeof(buf));
199 av_strlcat(buf,
" ",
sizeof(buf));
200 av_strlcat(buf, po->
argname,
sizeof(buf));
202 printf(
"-%-17s %s\n", buf, po->
help);
209 const AVClass *child = NULL;
211 av_opt_show2(&
class, NULL, flags, 0);
215 while ((child = av_opt_child_class_next(
class, child)))
221 const char *p = strchr(name,
':');
222 int len = p ? p - name : strlen(name);
225 if (!strncmp(name, po->
name, len) && strlen(po->
name) == len)
235 #if HAVE_COMMANDLINETOARGVW && defined(_WIN32) 236 #include <shellapi.h> 238 static char** win32_argv_utf8 = NULL;
239 static int win32_argc = 0;
252 int i, buffsize = 0, offset = 0;
254 if (win32_argv_utf8) {
255 *argc_ptr = win32_argc;
256 *argv_ptr = win32_argv_utf8;
261 argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc);
262 if (win32_argc <= 0 || !argv_w)
266 for (i = 0; i < win32_argc; i++)
267 buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
268 NULL, 0, NULL, NULL);
270 win32_argv_utf8 = av_mallocz(
sizeof(
char *) * (win32_argc + 1) + buffsize);
271 argstr_flat = (
char *)win32_argv_utf8 +
sizeof(
char *) * (win32_argc + 1);
272 if (!win32_argv_utf8) {
277 for (i = 0; i < win32_argc; i++) {
278 win32_argv_utf8[i] = &argstr_flat[offset];
279 offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
280 &argstr_flat[offset],
281 buffsize - offset, NULL, NULL);
283 win32_argv_utf8[i] = NULL;
286 *argc_ptr = win32_argc;
287 *argv_ptr = win32_argv_utf8;
307 char *p = strchr(opt,
':');
310 dstcount = (
int *)(so + 1);
311 *so =
grow_array(*so,
sizeof(**so), dstcount, *dstcount + 1);
312 str = av_strdup(p ? p + 1 :
"");
314 return AVERROR(ENOMEM);
315 (*so)[*dstcount - 1].specifier = str;
316 dst = &(*so)[*dstcount - 1].u;
321 str = av_strdup(arg);
324 return AVERROR(ENOMEM);
337 int ret = po->
u.
func_arg(optctx, opt, arg);
339 av_log(NULL, AV_LOG_ERROR,
340 "Failed to set value '%s' for option '%s': %s\n",
341 arg, opt, av_err2str(ret));
358 if (!po->
name && opt[0] ==
'n' && opt[1] ==
'o') {
369 av_log(NULL, AV_LOG_ERROR,
"Unrecognized option '%s'\n", opt);
370 return AVERROR(EINVAL);
373 av_log(NULL, AV_LOG_ERROR,
"Missing argument for option '%s'\n", opt);
374 return AVERROR(EINVAL);
385 void (*parse_arg_function)(
void *,
const char*))
388 int optindex, handleoptions = 1, ret;
395 while (optindex < argc) {
396 opt = argv[optindex++];
398 if (handleoptions && opt[0] ==
'-' && opt[1] !=
'\0') {
399 if (opt[1] ==
'-' && opt[2] ==
'\0') {
405 if (optindex < argc) {
411 if (parse_arg_function)
412 parse_arg_function(optctx, opt);
421 av_log(NULL, AV_LOG_DEBUG,
"Parsing a group of options: %s %s.\n",
424 for (i = 0; i < g->
nb_opts; i++) {
429 av_log(NULL, AV_LOG_ERROR,
"Option %s (%s) cannot be applied to " 430 "%s %s -- you are trying to apply an input option to an " 431 "output file or vice versa. Move this option before the " 432 "file it belongs to.\n", o->
key, o->
opt->
help,
434 return AVERROR(EINVAL);
437 av_log(NULL, AV_LOG_DEBUG,
"Applying option %s (%s) with argument %s.\n",
445 av_log(NULL, AV_LOG_DEBUG,
"Successfully parsed a group of options.\n");
456 for (i = 1; i < argc; i++) {
457 const char *cur_opt = argv[i];
459 if (*cur_opt++ !=
'-')
463 if (!po->
name && cur_opt[0] ==
'n' && cur_opt[1] ==
'o')
466 if ((!po->
name && !strcmp(cur_opt, optname)) ||
467 (po->
name && !strcmp(optname, po->
name)))
478 const unsigned char *p;
481 if (!((*p >=
'+' && *p <=
':') || (*p >=
'@' && *p <=
'Z') ||
482 *p ==
'_' || (*p >=
'a' && *p <=
'z')))
489 for (p = a; *p; p++) {
490 if (*p ==
'\\' || *p ==
'"' || *p ==
'$' || *p ==
'`')
492 else if (*p < ' ' || *p >
'~')
518 if (idx && (idx + 1 < argc) && argv[idx + 1])
521 if ((env = getenv(
"FFREPORT")) || idx) {
526 for (i = 0; i < argc; i++) {
538 static const AVOption *
opt_find(
void *obj,
const char *name,
const char *unit,
539 int opt_flags,
int search_flags)
541 const AVOption *o = av_opt_find(obj, name, unit, opt_flags, search_flags);
547 #define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 552 char opt_stripped[128];
554 const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
555 #if CONFIG_AVRESAMPLE 556 const AVClass *rc = avresample_get_class();
559 const AVClass *sc = sws_get_class();
561 #if CONFIG_SWRESAMPLE 562 const AVClass *swr_class = swr_get_class();
565 if (!strcmp(opt,
"debug") || !strcmp(opt,
"fdebug"))
566 av_log_set_level(AV_LOG_DEBUG);
568 if (!(p = strchr(opt,
':')))
569 p = opt + strlen(opt);
570 av_strlcpy(opt_stripped, opt, FFMIN(
sizeof(opt_stripped), p - opt + 1));
572 if ((o =
opt_find(&cc, opt_stripped, NULL, 0,
573 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) ||
574 ((opt[0] ==
'v' || opt[0] ==
'a' || opt[0] ==
's') &&
575 (o =
opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) {
579 if ((o =
opt_find(&fc, opt, NULL, 0,
580 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
583 av_log(NULL, AV_LOG_VERBOSE,
"Routing option %s to both codec and muxer layer\n", opt);
587 if (!consumed && (o =
opt_find(&sc, opt, NULL, 0,
588 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
589 struct SwsContext *sws = sws_alloc_context();
590 int ret = av_opt_set(sws, opt, arg, 0);
591 sws_freeContext(sws);
592 if (!strcmp(opt,
"srcw") || !strcmp(opt,
"srch") ||
593 !strcmp(opt,
"dstw") || !strcmp(opt,
"dsth") ||
594 !strcmp(opt,
"src_format") || !strcmp(opt,
"dst_format")) {
595 av_log(NULL, AV_LOG_ERROR,
"Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n");
596 return AVERROR(EINVAL);
599 av_log(NULL, AV_LOG_ERROR,
"Error setting option %s.\n", opt);
608 if (!consumed && !strcmp(opt,
"sws_flags")) {
609 av_log(NULL, AV_LOG_WARNING,
"Ignoring %s %s, due to disabled swscale\n", opt, arg);
613 #if CONFIG_SWRESAMPLE 614 if (!consumed && (o=
opt_find(&swr_class, opt, NULL, 0,
615 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
616 struct SwrContext *swr = swr_alloc();
617 int ret = av_opt_set(swr, opt, arg, 0);
620 av_log(NULL, AV_LOG_ERROR,
"Error setting option %s.\n", opt);
627 #if CONFIG_AVRESAMPLE 629 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
637 return AVERROR_OPTION_NOT_FOUND;
650 for (i = 0; i < nb_groups; i++) {
652 if (p->
sep && !strcmp(p->
sep, opt))
697 const char *key,
const char *val)
714 memset(octx, 0,
sizeof(*octx));
767 av_log(NULL, AV_LOG_DEBUG,
"Splitting the commandline.\n");
769 while (optindex < argc) {
770 const char *opt = argv[optindex++], *arg;
774 av_log(NULL, AV_LOG_DEBUG,
"Reading option '%s' ...", opt);
776 if (opt[0] ==
'-' && opt[1] ==
'-' && !opt[2]) {
781 if (opt[0] !=
'-' || !opt[1] || dashdash+1 == optindex) {
783 av_log(NULL, AV_LOG_DEBUG,
" matched as %s.\n", groups[0].name);
788 #define GET_ARG(arg) \ 790 if (optindex < argc) { \ 791 arg = argv[optindex++]; \ 793 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\ 794 return AVERROR(EINVAL); \ 802 av_log(NULL, AV_LOG_DEBUG,
" matched as %s with argument '%s'.\n",
803 groups[ret].name, arg);
812 if (optindex < argc) {
813 arg = argv[optindex++];
824 av_log(NULL, AV_LOG_DEBUG,
" matched as option '%s' (%s) with " 825 "argument '%s'.\n", po->
name, po->
help, arg);
830 if ((optindex < argc) && argv[optindex]) {
833 av_log(NULL, AV_LOG_DEBUG,
" matched as AVOption '%s' with " 834 "argument '%s'.\n", opt, argv[optindex]);
837 }
else if (ret != AVERROR_OPTION_NOT_FOUND) {
838 av_log(NULL, AV_LOG_ERROR,
"Error parsing option '%s' " 839 "with argument '%s'.\n", opt, argv[optindex]);
845 if (opt[0] ==
'n' && opt[1] ==
'o' &&
849 av_log(NULL, AV_LOG_DEBUG,
" matched as option '%s' (%s) with " 850 "argument 0.\n", po->
name, po->
help);
854 av_log(NULL, AV_LOG_ERROR,
"Unrecognized option '%s'.\n", opt);
855 return AVERROR_OPTION_NOT_FOUND;
859 av_log(NULL, AV_LOG_WARNING,
"Trailing options were found on the " 862 av_log(NULL, AV_LOG_DEBUG,
"Finished splitting the commandline.\n");
870 unsigned flags = av_get_cpu_flags();
872 if ((ret = av_parse_cpu_caps(&flags, arg)) < 0)
875 av_force_cpu_flags(flags);
881 const struct {
const char *name;
int level; } log_levels[] = {
882 {
"quiet" , AV_LOG_QUIET },
883 {
"panic" , AV_LOG_PANIC },
884 {
"fatal" , AV_LOG_FATAL },
885 {
"error" , AV_LOG_ERROR },
886 {
"warning", AV_LOG_WARNING },
887 {
"info" , AV_LOG_INFO },
888 {
"verbose", AV_LOG_VERBOSE },
889 {
"debug" , AV_LOG_DEBUG },
890 {
"trace" , AV_LOG_TRACE },
894 int flags = av_log_get_flags();
895 int level = av_log_get_level();
901 if (*token ==
'+' || *token ==
'-') {
909 if (!strncmp(token,
"repeat", 6)) {
911 flags |= AV_LOG_SKIP_REPEATED;
913 flags &= ~AV_LOG_SKIP_REPEATED;
916 }
else if (!strncmp(token,
"level", 5)) {
918 flags &= ~AV_LOG_PRINT_LEVEL;
920 flags |= AV_LOG_PRINT_LEVEL;
930 }
else if (*arg ==
'+') {
933 flags = av_log_get_flags();
936 for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) {
937 if (!strcmp(log_levels[i].name, arg)) {
938 level = log_levels[i].level;
943 level = strtol(arg, &tail, 10);
945 av_log(NULL, AV_LOG_FATAL,
"Invalid loglevel \"%s\". " 946 "Possible levels are numbers or:\n", arg);
947 for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
948 av_log(NULL, AV_LOG_FATAL,
"\"%s\"\n", log_levels[i].name);
953 av_log_set_flags(flags);
954 av_log_set_level(level);
963 while ((c = *(
template++))) {
965 if (!(c = *(
template++)))
972 av_bprintf(bp,
"%04d%02d%02d-%02d%02d%02d",
973 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
974 tm->tm_hour, tm->tm_min, tm->tm_sec);
977 av_bprint_chars(bp, c, 1);
981 av_bprint_chars(bp, c, 1);
988 char *filename_template = NULL;
998 tm = localtime(&now);
1000 while (env && *env) {
1001 if ((ret = av_opt_get_key_value(&env,
"=",
":", 0, &key, &val)) < 0) {
1003 av_log(NULL, AV_LOG_ERROR,
1004 "Failed to parse FFREPORT environment variable: %s\n",
1011 if (!strcmp(key,
"file")) {
1012 av_free(filename_template);
1013 filename_template = val;
1015 }
else if (!strcmp(key,
"level")) {
1019 av_log(NULL, AV_LOG_FATAL,
"Invalid report file level\n");
1023 av_log(NULL, AV_LOG_ERROR,
"Unknown key '%s' in FFREPORT\n", key);
1029 av_bprint_init(&filename, 0, AV_BPRINT_SIZE_AUTOMATIC);
1031 av_x_if_null(filename_template,
"%p-%t.log"), tm);
1032 av_free(filename_template);
1033 if (!av_bprint_is_complete(&filename)) {
1034 av_log(NULL, AV_LOG_ERROR,
"Out of memory building report file name\n");
1035 return AVERROR(ENOMEM);
1040 int ret = AVERROR(errno);
1041 av_log(NULL, AV_LOG_ERROR,
"Failed to open report \"%s\": %s\n",
1042 filename.str, strerror(errno));
1046 av_log(NULL, AV_LOG_INFO,
1047 "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n" 1048 "Report written to \"%s\"\n",
1050 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
1051 tm->tm_hour, tm->tm_min, tm->tm_sec,
1053 av_bprint_finalize(&filename, NULL);
1067 max = strtol(arg, &tail, 10);
1069 av_log(NULL, AV_LOG_FATAL,
"Invalid max_alloc \"%s\".\n", arg);
1080 struct rlimit rl = { lim, lim + 1 };
1081 if (setrlimit(RLIMIT_CPU, &rl))
1082 perror(
"setrlimit");
1084 av_log(NULL, AV_LOG_WARNING,
"-%s not implemented on this OS\n", opt);
1092 const char *errbuf_ptr = errbuf;
1094 if (av_strerror(err, errbuf,
sizeof(errbuf)) < 0)
1095 errbuf_ptr = strerror(AVUNERROR(err));
1096 av_log(NULL, AV_LOG_ERROR,
"%s: %s\n", filename, errbuf_ptr);
1102 #define SHOW_VERSION 2 1103 #define SHOW_CONFIG 4 1104 #define SHOW_COPYRIGHT 8 1106 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ 1107 if (CONFIG_##LIBNAME) { \ 1108 const char *indent = flags & INDENT? " " : ""; \ 1109 if (flags & SHOW_VERSION) { \ 1110 unsigned int version = libname##_version(); \ 1111 av_log(NULL, level, \ 1112 "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \ 1114 LIB##LIBNAME##_VERSION_MAJOR, \ 1115 LIB##LIBNAME##_VERSION_MINOR, \ 1116 LIB##LIBNAME##_VERSION_MICRO, \ 1117 AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\ 1118 AV_VERSION_MICRO(version)); \ 1120 if (flags & SHOW_CONFIG) { \ 1121 const char *cfg = libname##_configuration(); \ 1122 if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \ 1123 if (!warned_cfg) { \ 1124 av_log(NULL, level, \ 1125 "%sWARNING: library configuration mismatch\n", \ 1129 av_log(NULL, level, "%s%-11s configuration: %s\n", \ 1130 indent, #libname, cfg); \ 1148 const char *indent = flags &
INDENT?
" " :
"";
1150 av_log(NULL, level,
"%s version " FFMPEG_VERSION,
program_name);
1152 av_log(NULL, level,
" Copyright (c) %d-%d the FFmpeg developers",
1154 av_log(NULL, level,
"\n");
1155 av_log(NULL, level,
"%sbuilt with %s\n", indent, CC_IDENT);
1157 av_log(NULL, level,
"%sconfiguration: " FFMPEG_CONFIGURATION
"\n", indent);
1162 const char *indent = flags &
INDENT ?
" " :
"";
1163 char str[] = { FFMPEG_CONFIGURATION };
1164 char *conflist, *remove_tilde, *splitconf;
1168 while ((conflist = strstr(str,
" --")) != NULL) {
1169 strncpy(conflist,
"~--", 3);
1174 while ((remove_tilde = strstr(str,
"pkg-config~")) != NULL) {
1175 strncpy(remove_tilde,
"pkg-config ", 11);
1178 splitconf = strtok(str,
"~");
1179 av_log(NULL, level,
"\n%sconfiguration:\n", indent);
1180 while (splitconf != NULL) {
1181 av_log(NULL, level,
"%s%s%s\n", indent, indent, splitconf);
1182 splitconf = strtok(NULL,
"~");
1218 "This version of %s has nonfree parts compiled in.\n" 1219 "Therefore it is not legally redistributable.\n",
1223 "%s is free software; you can redistribute it and/or modify\n" 1224 "it under the terms of the GNU General Public License as published by\n" 1225 "the Free Software Foundation; either version 3 of the License, or\n" 1226 "(at your option) any later version.\n" 1228 "%s is distributed in the hope that it will be useful,\n" 1229 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 1230 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 1231 "GNU General Public License for more details.\n" 1233 "You should have received a copy of the GNU General Public License\n" 1234 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
1238 "%s is free software; you can redistribute it and/or modify\n" 1239 "it under the terms of the GNU General Public License as published by\n" 1240 "the Free Software Foundation; either version 2 of the License, or\n" 1241 "(at your option) any later version.\n" 1243 "%s is distributed in the hope that it will be useful,\n" 1244 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 1245 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 1246 "GNU General Public License for more details.\n" 1248 "You should have received a copy of the GNU General Public License\n" 1249 "along with %s; if not, write to the Free Software\n" 1250 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
1254 "%s is free software; you can redistribute it and/or modify\n" 1255 "it under the terms of the GNU Lesser General Public License as published by\n" 1256 "the Free Software Foundation; either version 3 of the License, or\n" 1257 "(at your option) any later version.\n" 1259 "%s is distributed in the hope that it will be useful,\n" 1260 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 1261 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 1262 "GNU Lesser General Public License for more details.\n" 1264 "You should have received a copy of the GNU Lesser General Public License\n" 1265 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
1269 "%s is free software; you can redistribute it and/or\n" 1270 "modify it under the terms of the GNU Lesser General Public\n" 1271 "License as published by the Free Software Foundation; either\n" 1272 "version 2.1 of the License, or (at your option) any later version.\n" 1274 "%s is distributed in the hope that it will be useful,\n" 1275 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 1276 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" 1277 "Lesser General Public License for more details.\n" 1279 "You should have received a copy of the GNU Lesser General Public\n" 1280 "License along with %s; if not, write to the Free Software\n" 1281 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
1292 return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
1297 void *ifmt_opaque = NULL;
1298 const AVInputFormat *ifmt = NULL;
1299 void *ofmt_opaque = NULL;
1300 const AVOutputFormat *ofmt = NULL;
1301 const char *last_name;
1305 " D. = Demuxing supported\n" 1306 " .E = Muxing supported\n" 1307 " --\n", device_only ?
"Devices:" :
"File formats:");
1312 const char *name = NULL;
1313 const char *long_name = NULL;
1317 while ((ofmt = av_muxer_iterate(&ofmt_opaque))) {
1319 if (!is_dev && device_only)
1321 if ((!name || strcmp(ofmt->name, name) < 0) &&
1322 strcmp(ofmt->name, last_name) > 0) {
1324 long_name = ofmt->long_name;
1331 while ((ifmt = av_demuxer_iterate(&ifmt_opaque))) {
1333 if (!is_dev && device_only)
1335 if ((!name || strcmp(ifmt->name, name) < 0) &&
1336 strcmp(ifmt->name, last_name) > 0) {
1338 long_name = ifmt->long_name;
1341 if (name && strcmp(ifmt->name, name) == 0)
1349 printf(
" %s%s %-15s %s\n",
1353 long_name ? long_name:
" ");
1378 #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ 1379 if (codec->field) { \ 1380 const type *p = codec->field; \ 1382 printf(" Supported " list_name ":"); \ 1383 while (*p != term) { \ 1385 printf(" %s", name); \ 1393 int encoder = av_codec_is_encoder(c);
1395 printf(
"%s %s [%s]:\n", encoder ?
"Encoder" :
"Decoder", c->name,
1396 c->long_name ? c->long_name :
"");
1398 printf(
" General capabilities: ");
1399 if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)
1400 printf(
"horizband ");
1401 if (c->capabilities & AV_CODEC_CAP_DR1)
1403 if (c->capabilities & AV_CODEC_CAP_TRUNCATED)
1405 if (c->capabilities & AV_CODEC_CAP_DELAY)
1407 if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)
1409 if (c->capabilities & AV_CODEC_CAP_SUBFRAMES)
1410 printf(
"subframes ");
1411 if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL)
1413 if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF)
1415 if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE)
1416 printf(
"paramchange ");
1417 if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
1418 printf(
"variable ");
1419 if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
1420 AV_CODEC_CAP_SLICE_THREADS |
1421 AV_CODEC_CAP_AUTO_THREADS))
1423 if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
1424 printf(
"avoidprobe ");
1425 if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY)
1426 printf(
"intraonly ");
1427 if (c->capabilities & AV_CODEC_CAP_LOSSLESS)
1428 printf(
"lossless ");
1429 if (c->capabilities & AV_CODEC_CAP_HARDWARE)
1430 printf(
"hardware ");
1431 if (c->capabilities & AV_CODEC_CAP_HYBRID)
1433 if (!c->capabilities)
1437 if (c->type == AVMEDIA_TYPE_VIDEO ||
1438 c->type == AVMEDIA_TYPE_AUDIO) {
1439 printf(
" Threading capabilities: ");
1440 switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
1441 AV_CODEC_CAP_SLICE_THREADS |
1442 AV_CODEC_CAP_AUTO_THREADS)) {
1443 case AV_CODEC_CAP_FRAME_THREADS |
1444 AV_CODEC_CAP_SLICE_THREADS: printf(
"frame and slice");
break;
1445 case AV_CODEC_CAP_FRAME_THREADS: printf(
"frame");
break;
1446 case AV_CODEC_CAP_SLICE_THREADS: printf(
"slice");
break;
1447 case AV_CODEC_CAP_AUTO_THREADS : printf(
"auto");
break;
1448 default: printf(
"none");
break;
1453 if (avcodec_get_hw_config(c, 0)) {
1454 printf(
" Supported hardware devices: ");
1455 for (
int i = 0;; i++) {
1456 const AVCodecHWConfig *config = avcodec_get_hw_config(c, i);
1459 printf(
"%s ", av_hwdevice_get_type_name(config->device_type));
1464 if (c->supported_framerates) {
1465 const AVRational *fps = c->supported_framerates;
1467 printf(
" Supported framerates:");
1469 printf(
" %d/%d", fps->num, fps->den);
1483 if (c->priv_class) {
1485 AV_OPT_FLAG_ENCODING_PARAM |
1486 AV_OPT_FLAG_DECODING_PARAM);
1493 case AVMEDIA_TYPE_VIDEO:
return 'V';
1494 case AVMEDIA_TYPE_AUDIO:
return 'A';
1495 case AVMEDIA_TYPE_DATA:
return 'D';
1496 case AVMEDIA_TYPE_SUBTITLE:
return 'S';
1497 case AVMEDIA_TYPE_ATTACHMENT:
return 'T';
1498 default:
return '?';
1505 while ((prev = av_codec_next(prev))) {
1506 if (prev->id ==
id &&
1507 (encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
1515 const AVCodecDescriptor *
const *da = a;
1516 const AVCodecDescriptor *
const *db = b;
1518 return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) :
1519 strcmp((*da)->name, (*db)->name);
1524 const AVCodecDescriptor *desc = NULL;
1525 const AVCodecDescriptor **codecs;
1526 unsigned nb_codecs = 0, i = 0;
1528 while ((desc = avcodec_descriptor_next(desc)))
1530 if (!(codecs = av_calloc(nb_codecs,
sizeof(*codecs)))) {
1531 av_log(NULL, AV_LOG_ERROR,
"Out of memory\n");
1535 while ((desc = avcodec_descriptor_next(desc)))
1537 av_assert0(i == nb_codecs);
1545 const AVCodec *
codec = NULL;
1547 printf(
" (%s: ", encoder ?
"encoders" :
"decoders");
1550 printf(
"%s ",
codec->name);
1557 const AVCodecDescriptor **codecs;
1561 " D..... = Decoding supported\n" 1562 " .E.... = Encoding supported\n" 1563 " ..V... = Video codec\n" 1564 " ..A... = Audio codec\n" 1565 " ..S... = Subtitle codec\n" 1566 " ...I.. = Intra frame-only codec\n" 1567 " ....L. = Lossy compression\n" 1568 " .....S = Lossless compression\n" 1570 for (i = 0; i < nb_codecs; i++) {
1571 const AVCodecDescriptor *desc = codecs[i];
1572 const AVCodec *
codec = NULL;
1574 if (strstr(desc->name,
"_deprecated"))
1578 printf(avcodec_find_decoder(desc->id) ?
"D" :
".");
1579 printf(avcodec_find_encoder(desc->id) ?
"E" :
".");
1582 printf((desc->props & AV_CODEC_PROP_INTRA_ONLY) ?
"I" :
".");
1583 printf((desc->props & AV_CODEC_PROP_LOSSY) ?
"L" :
".");
1584 printf((desc->props & AV_CODEC_PROP_LOSSLESS) ?
"S" :
".");
1586 printf(
" %-20s %s", desc->name, desc->long_name ? desc->long_name :
"");
1591 if (strcmp(
codec->name, desc->name)) {
1598 if (strcmp(
codec->name, desc->name)) {
1612 const AVCodecDescriptor **codecs;
1618 " S..... = Subtitle\n" 1619 " .F.... = Frame-level multithreading\n" 1620 " ..S... = Slice-level multithreading\n" 1621 " ...X.. = Codec is experimental\n" 1622 " ....B. = Supports draw_horiz_band\n" 1623 " .....D = Supports direct rendering method 1\n" 1625 encoder ?
"Encoders" :
"Decoders");
1626 for (i = 0; i < nb_codecs; i++) {
1627 const AVCodecDescriptor *desc = codecs[i];
1628 const AVCodec *
codec = NULL;
1632 printf((
codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ?
"F" :
".");
1633 printf((
codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ?
"S" :
".");
1634 printf((
codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ?
"X" :
".");
1635 printf((
codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?
"B" :
".");
1636 printf((
codec->capabilities & AV_CODEC_CAP_DR1) ?
"D" :
".");
1638 printf(
" %-20s %s",
codec->name,
codec->long_name ?
codec->long_name :
"");
1639 if (strcmp(
codec->name, desc->name))
1640 printf(
" (codec %s)", desc->name);
1660 int show_bsfs(
void *optctx,
const char *opt,
const char *arg)
1662 const AVBitStreamFilter *bsf = NULL;
1663 void *opaque = NULL;
1665 printf(
"Bitstream filters:\n");
1666 while ((bsf = av_bsf_iterate(&opaque)))
1667 printf(
"%s\n", bsf->name);
1674 void *opaque = NULL;
1677 printf(
"Supported file protocols:\n" 1679 while ((name = avio_enum_protocols(&opaque, 0)))
1680 printf(
" %s\n", name);
1681 printf(
"Output:\n");
1682 while ((name = avio_enum_protocols(&opaque, 1)))
1683 printf(
" %s\n", name);
1690 const AVFilter *filter = NULL;
1691 char descr[64], *descr_cur;
1692 void *opaque = NULL;
1694 const AVFilterPad *pad;
1697 " T.. = Timeline support\n" 1698 " .S. = Slice threading\n" 1699 " ..C = Command support\n" 1700 " A = Audio input/output\n" 1701 " V = Video input/output\n" 1702 " N = Dynamic number and/or type of input/output\n" 1703 " | = Source or sink filter\n");
1704 while ((filter = av_filter_iterate(&opaque))) {
1706 for (i = 0; i < 2; i++) {
1708 *(descr_cur++) =
'-';
1709 *(descr_cur++) =
'>';
1711 pad = i ? filter->outputs : filter->inputs;
1712 for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) {
1713 if (descr_cur >= descr +
sizeof(descr) - 4)
1718 *(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) ||
1719 ( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ?
'N' :
'|';
1722 printf(
" %c%c%c %-17s %-10s %s\n",
1723 filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ?
'T' :
'.',
1724 filter->flags & AVFILTER_FLAG_SLICE_THREADS ?
'S' :
'.',
1725 filter->process_command ?
'C' :
'.',
1726 filter->name, descr, filter->description);
1729 printf(
"No filters available: libavfilter disabled\n");
1740 printf(
"%-32s #RRGGBB\n",
"name");
1742 for (i = 0; (name = av_get_known_color_name(i, &rgb)); i++)
1743 printf(
"%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]);
1750 const AVPixFmtDescriptor *pix_desc = NULL;
1752 printf(
"Pixel formats:\n" 1753 "I.... = Supported Input format for conversion\n" 1754 ".O... = Supported Output format for conversion\n" 1755 "..H.. = Hardware accelerated format\n" 1756 "...P. = Paletted format\n" 1757 "....B = Bitstream format\n" 1758 "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n" 1762 # define sws_isSupportedInput(x) 0 1763 # define sws_isSupportedOutput(x) 0 1766 while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
1767 enum AVPixelFormat av_unused pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
1768 printf(
"%c%c%c%c%c %-16s %d %2d\n",
1771 pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL ?
'H' :
'.',
1772 pix_desc->flags & AV_PIX_FMT_FLAG_PAL ?
'P' :
'.',
1773 pix_desc->flags & AV_PIX_FMT_FLAG_BITSTREAM ?
'B' :
'.',
1775 pix_desc->nb_components,
1776 av_get_bits_per_pixel(pix_desc));
1785 const char *name, *descr;
1787 printf(
"Individual channels:\n" 1788 "NAME DESCRIPTION\n");
1789 for (i = 0; i < 63; i++) {
1790 name = av_get_channel_name((uint64_t)1 << i);
1793 descr = av_get_channel_description((uint64_t)1 << i);
1794 printf(
"%-14s %s\n", name, descr);
1796 printf(
"\nStandard channel layouts:\n" 1797 "NAME DECOMPOSITION\n");
1798 for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) {
1800 printf(
"%-14s ", name);
1801 for (j = 1; j; j <<= 1)
1803 printf(
"%s%s", (layout & (j - 1)) ?
"+" :
"", av_get_channel_name(j));
1814 for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
1815 printf(
"%s\n", av_get_sample_fmt_string(fmt_str,
sizeof(fmt_str), i));
1821 const AVCodecDescriptor *desc;
1822 const AVCodec *
codec;
1825 av_log(NULL, AV_LOG_ERROR,
"No codec name specified.\n");
1829 codec = encoder ? avcodec_find_encoder_by_name(name) :
1830 avcodec_find_decoder_by_name(name);
1834 else if ((desc = avcodec_descriptor_get_by_name(name))) {
1843 av_log(NULL, AV_LOG_ERROR,
"Codec '%s' is known to FFmpeg, " 1844 "but no %s for it are available. FFmpeg might need to be " 1845 "recompiled with additional external libraries.\n",
1846 name, encoder ?
"encoders" :
"decoders");
1849 av_log(NULL, AV_LOG_ERROR,
"Codec '%s' is not recognized by FFmpeg.\n",
1856 const AVInputFormat *fmt = av_find_input_format(name);
1859 av_log(NULL, AV_LOG_ERROR,
"Unknown format '%s'.\n", name);
1863 printf(
"Demuxer %s [%s]:\n", fmt->name, fmt->long_name);
1865 if (fmt->extensions)
1866 printf(
" Common extensions: %s.\n", fmt->extensions);
1868 if (fmt->priv_class)
1874 const AVCodecDescriptor *desc;
1875 const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL);
1878 av_log(NULL, AV_LOG_ERROR,
"Unknown format '%s'.\n", name);
1882 printf(
"Muxer %s [%s]:\n", fmt->name, fmt->long_name);
1884 if (fmt->extensions)
1885 printf(
" Common extensions: %s.\n", fmt->extensions);
1887 printf(
" Mime type: %s.\n", fmt->mime_type);
1888 if (fmt->video_codec != AV_CODEC_ID_NONE &&
1889 (desc = avcodec_descriptor_get(fmt->video_codec))) {
1890 printf(
" Default video codec: %s.\n", desc->name);
1892 if (fmt->audio_codec != AV_CODEC_ID_NONE &&
1893 (desc = avcodec_descriptor_get(fmt->audio_codec))) {
1894 printf(
" Default audio codec: %s.\n", desc->name);
1896 if (fmt->subtitle_codec != AV_CODEC_ID_NONE &&
1897 (desc = avcodec_descriptor_get(fmt->subtitle_codec))) {
1898 printf(
" Default subtitle codec: %s.\n", desc->name);
1901 if (fmt->priv_class)
1906 static void show_help_filter(
const char *name)
1909 const AVFilter *f = avfilter_get_by_name(name);
1913 av_log(NULL, AV_LOG_ERROR,
"No filter name specified.\n");
1916 av_log(NULL, AV_LOG_ERROR,
"Unknown filter '%s'.\n", name);
1920 printf(
"Filter %s\n", f->name);
1922 printf(
" %s\n", f->description);
1924 if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
1925 printf(
" slice threading supported\n");
1927 printf(
" Inputs:\n");
1928 count = avfilter_pad_count(f->inputs);
1929 for (i = 0; i < count; i++) {
1930 printf(
" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
1933 if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
1934 printf(
" dynamic (depending on the options)\n");
1936 printf(
" none (source filter)\n");
1938 printf(
" Outputs:\n");
1939 count = avfilter_pad_count(f->outputs);
1940 for (i = 0; i < count; i++) {
1941 printf(
" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i),
1944 if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
1945 printf(
" dynamic (depending on the options)\n");
1947 printf(
" none (sink filter)\n");
1950 show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM |
1951 AV_OPT_FLAG_AUDIO_PARAM);
1952 if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
1953 printf(
"This filter has support for timeline through the 'enable' option.\n");
1955 av_log(NULL, AV_LOG_ERROR,
"Build without libavfilter; " 1956 "can not to satisfy request\n");
1963 const AVBitStreamFilter *bsf = av_bsf_get_by_name(name);
1966 av_log(NULL, AV_LOG_ERROR,
"No bitstream filter name specified.\n");
1969 av_log(NULL, AV_LOG_ERROR,
"Unknown bit stream filter '%s'.\n", name);
1973 printf(
"Bit stream filter %s\n", bsf->name);
1976 if (bsf->priv_class)
1980 int show_help(
void *optctx,
const char *opt,
const char *arg)
1985 topic = av_strdup(arg ? arg :
"");
1987 return AVERROR(ENOMEM);
1988 par = strchr(topic,
'=');
1994 }
else if (!strcmp(topic,
"decoder")) {
1996 }
else if (!strcmp(topic,
"encoder")) {
1998 }
else if (!strcmp(topic,
"demuxer")) {
2000 }
else if (!strcmp(topic,
"muxer")) {
2003 }
else if (!strcmp(topic,
"filter")) {
2004 show_help_filter(par);
2006 }
else if (!strcmp(topic,
"bsf")) {
2019 int yesno = (av_toupper(c) ==
'Y');
2021 while (c !=
'\n' && c != EOF)
2028 const char *preset_name,
int is_path,
2029 const char *codec_name)
2033 const char *base[3] = { getenv(
"FFMPEG_DATADIR"),
2038 av_strlcpy(filename, preset_name, filename_size);
2039 f = fopen(filename,
"r");
2042 char datadir[MAX_PATH], *ls;
2045 if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir,
sizeof(datadir) - 1))
2047 for (ls = datadir; ls < datadir + strlen(datadir); ls++)
2048 if (*ls ==
'\\') *ls =
'/';
2050 if (ls = strrchr(datadir,
'/'))
2053 strncat(datadir,
"/ffpresets",
sizeof(datadir) - 1 - strlen(datadir));
2058 for (i = 0; i < 3 && !f; i++) {
2061 snprintf(filename, filename_size,
"%s%s/%s.ffpreset", base[i],
2062 i != 1 ?
"" :
"/.ffmpeg", preset_name);
2063 f = fopen(filename,
"r");
2064 if (!f && codec_name) {
2065 snprintf(filename, filename_size,
2066 "%s%s/%s-%s.ffpreset",
2067 base[i], i != 1 ?
"" :
"/.ffmpeg", codec_name,
2069 f = fopen(filename,
"r");
2079 int ret = avformat_match_stream_specifier(s, st, spec);
2081 av_log(s, AV_LOG_ERROR,
"Invalid stream specifier: %s.\n", spec);
2086 AVFormatContext *s, AVStream *st, AVCodec *
codec)
2088 AVDictionary *ret = NULL;
2089 AVDictionaryEntry *t = NULL;
2090 int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM
2091 : AV_OPT_FLAG_DECODING_PARAM;
2093 const AVClass *cc = avcodec_get_class();
2096 codec = s->oformat ? avcodec_find_encoder(codec_id)
2097 : avcodec_find_decoder(codec_id);
2099 switch (st->codecpar->codec_type) {
2100 case AVMEDIA_TYPE_VIDEO:
2102 flags |= AV_OPT_FLAG_VIDEO_PARAM;
2104 case AVMEDIA_TYPE_AUDIO:
2106 flags |= AV_OPT_FLAG_AUDIO_PARAM;
2108 case AVMEDIA_TYPE_SUBTITLE:
2110 flags |= AV_OPT_FLAG_SUBTITLE_PARAM;
2114 while ((t = av_dict_get(opts,
"", t, AV_DICT_IGNORE_SUFFIX))) {
2115 char *p = strchr(t->key,
':');
2120 case 1: *p = 0;
break;
2125 if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) ||
2127 (
codec->priv_class &&
2128 av_opt_find(&
codec->priv_class, t->key, NULL, flags,
2129 AV_OPT_SEARCH_FAKE_OBJ)))
2130 av_dict_set(&ret, t->key, t->value, 0);
2131 else if (t->key[0] == prefix &&
2132 av_opt_find(&cc, t->key + 1, NULL, flags,
2133 AV_OPT_SEARCH_FAKE_OBJ))
2134 av_dict_set(&ret, t->key + 1, t->value, 0);
2146 AVDictionary **opts;
2150 opts = av_mallocz_array(s->nb_streams,
sizeof(*opts));
2152 av_log(NULL, AV_LOG_ERROR,
2153 "Could not alloc memory for stream options.\n");
2156 for (i = 0; i < s->nb_streams; i++)
2158 s, s->streams[i], NULL);
2164 if (new_size >= INT_MAX / elem_size) {
2165 av_log(NULL, AV_LOG_ERROR,
"Array too big.\n");
2168 if (*
size < new_size) {
2169 uint8_t *tmp = av_realloc_array(array, new_size, elem_size);
2171 av_log(NULL, AV_LOG_ERROR,
"Could not alloc buffer.\n");
2174 memset(tmp + *
size*elem_size, 0, (new_size-*
size) * elem_size);
2183 uint8_t* displaymatrix = av_stream_get_side_data(st,
2184 AV_PKT_DATA_DISPLAYMATRIX, NULL);
2187 theta = -av_display_rotation_get((int32_t*) displaymatrix);
2189 theta -= 360*floor(theta/360 + 0.9/360);
2191 if (fabs(theta - 90*round(theta/90)) > 2)
2192 av_log(NULL, AV_LOG_WARNING,
"Odd rotation angle.\n" 2193 "If you want to help, upload a sample " 2194 "of this file to ftp://upload.ffmpeg.org/incoming/ " 2195 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)");
2201 static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
2204 AVDeviceInfoList *device_list = NULL;
2206 if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
2207 return AVERROR(EINVAL);
2209 printf(
"Auto-detected sources for %s:\n", fmt->name);
2210 if (!fmt->get_device_list) {
2211 ret = AVERROR(ENOSYS);
2212 printf(
"Cannot list sources. Not implemented.\n");
2216 if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) {
2217 printf(
"Cannot list sources.\n");
2221 for (i = 0; i < device_list->nb_devices; i++) {
2222 printf(
"%s %s [%s]\n", device_list->default_device == i ?
"*" :
" ",
2223 device_list->devices[i]->device_name, device_list->devices[i]->device_description);
2227 avdevice_free_list_devices(&device_list);
2231 static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
2234 AVDeviceInfoList *device_list = NULL;
2236 if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
2237 return AVERROR(EINVAL);
2239 printf(
"Auto-detected sinks for %s:\n", fmt->name);
2240 if (!fmt->get_device_list) {
2241 ret = AVERROR(ENOSYS);
2242 printf(
"Cannot list sinks. Not implemented.\n");
2246 if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) {
2247 printf(
"Cannot list sinks.\n");
2251 for (i = 0; i < device_list->nb_devices; i++) {
2252 printf(
"%s %s [%s]\n", device_list->default_device == i ?
"*" :
" ",
2253 device_list->devices[i]->device_name, device_list->devices[i]->device_description);
2257 avdevice_free_list_devices(&device_list);
2261 static int show_sinks_sources_parse_arg(
const char *arg,
char **dev, AVDictionary **opts)
2265 char *opts_str = NULL;
2266 av_assert0(dev && opts);
2267 *dev = av_strdup(arg);
2269 return AVERROR(ENOMEM);
2270 if ((opts_str = strchr(*dev,
','))) {
2271 *(opts_str++) =
'\0';
2272 if (opts_str[0] && ((ret = av_dict_parse_string(opts, opts_str,
"=",
":", 0)) < 0)) {
2278 printf(
"\nDevice name is not provided.\n" 2279 "You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.\n\n");
2283 int show_sources(
void *optctx,
const char *opt,
const char *arg)
2285 AVInputFormat *fmt = NULL;
2287 AVDictionary *opts = NULL;
2289 int error_level = av_log_get_level();
2291 av_log_set_level(AV_LOG_ERROR);
2293 if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
2297 fmt = av_input_audio_device_next(fmt);
2299 if (!strcmp(fmt->name,
"lavfi"))
2301 if (dev && !av_match_name(dev, fmt->name))
2303 print_device_sources(fmt, opts);
2307 fmt = av_input_video_device_next(fmt);
2309 if (dev && !av_match_name(dev, fmt->name))
2311 print_device_sources(fmt, opts);
2315 av_dict_free(&opts);
2317 av_log_set_level(error_level);
2321 int show_sinks(
void *optctx,
const char *opt,
const char *arg)
2323 AVOutputFormat *fmt = NULL;
2325 AVDictionary *opts = NULL;
2327 int error_level = av_log_get_level();
2329 av_log_set_level(AV_LOG_ERROR);
2331 if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
2335 fmt = av_output_audio_device_next(fmt);
2337 if (dev && !av_match_name(dev, fmt->name))
2339 print_device_sinks(fmt, opts);
2343 fmt = av_output_video_device_next(fmt);
2345 if (dev && !av_match_name(dev, fmt->name))
2347 print_device_sinks(fmt, opts);
2351 av_dict_free(&opts);
2353 av_log_set_level(error_level);
const OptionGroupDef * group_def
AVDictionary * format_opts
AVDictionary * resample_opts
const OptionGroupDef * group_def
AVDictionary * codec_opts
int(* func_arg)(void *, const char *, const char *)