33 #include "libavformat/avformat.h"
34 #include "libavfilter/avfilter.h"
35 #include "libavdevice/avdevice.h"
36 #include "libavresample/avresample.h"
37 #include "libswscale/swscale.h"
38 #include "libavutil/avassert.h"
39 #include "libavutil/avstring.h"
40 #include "libavutil/mathematics.h"
41 #include "libavutil/imgutils.h"
42 #include "libavutil/parseutils.h"
43 #include "libavutil/pixdesc.h"
44 #include "libavutil/eval.h"
45 #include "libavutil/dict.h"
46 #include "libavutil/opt.h"
47 #include "libavutil/cpu.h"
53 #if HAVE_SYS_RESOURCE_H
55 #include <sys/resource.h>
84 vfprintf(stdout, fmt, vl);
103 double min,
double max)
109 error =
"Expected number for %s but found: %s\n";
110 else if (d < min || d > max)
111 error =
"The value for %s was %s which is not within %f - %f\n";
112 else if (type ==
OPT_INT64 && (int64_t)d != d)
113 error =
"Expected int64 for %s but found %s\n";
114 else if (type ==
OPT_INT && (
int)d != d)
115 error =
"Expected int for %s but found %s\n";
129 is_duration ?
"duration" :
"date", context, timestr);
136 int rej_flags,
int alt_flags)
142 for (po = options; po->
name !=
NULL; po++) {
145 if (((po->
flags & req_flags) != req_flags) ||
146 (alt_flags && !(po->
flags & alt_flags)) ||
147 (po->
flags & rej_flags))
159 printf(
"-%-17s %s\n", buf, po->
help);
176 const char *p = strchr(name,
':');
177 int len = p ? p - name : strlen(name);
180 if (!strncmp(name, po->
name, len) && strlen(po->
name) == len)
190 #if HAVE_COMMANDLINETOARGVW && defined(_WIN32)
192 #include <shellapi.h>
194 static char** win32_argv_utf8 =
NULL;
195 static int win32_argc = 0;
208 int i, buffsize = 0, offset = 0;
210 if (win32_argv_utf8) {
211 *argc_ptr = win32_argc;
212 *argv_ptr = win32_argv_utf8;
217 argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc);
218 if (win32_argc <= 0 || !argv_w)
222 for (i = 0; i < win32_argc; i++)
223 buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
226 win32_argv_utf8 =
av_mallocz(
sizeof(
char *) * (win32_argc + 1) + buffsize);
227 argstr_flat = (
char *)win32_argv_utf8 +
sizeof(
char *) * (win32_argc + 1);
228 if (!win32_argv_utf8) {
233 for (i = 0; i < win32_argc; i++) {
234 win32_argv_utf8[i] = &argstr_flat[offset];
235 offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1,
236 &argstr_flat[offset],
239 win32_argv_utf8[i] =
NULL;
242 *argc_ptr = win32_argc;
243 *argv_ptr = win32_argv_utf8;
263 char *p = strchr(opt,
':');
265 dstcount = (
int *)(so + 1);
266 *so =
grow_array(*so,
sizeof(**so), dstcount, *dstcount + 1);
267 (*so)[*dstcount - 1].specifier =
av_strdup(p ? p + 1 :
"");
268 dst = &(*so)[*dstcount - 1].u;
287 int ret = po->
u.
func_arg(optctx, opt, arg);
290 "Failed to set value '%s' for option '%s'\n", arg, opt);
307 if (!po->
name && opt[0] ==
'n' && opt[1] ==
'o') {
334 void (*parse_arg_function)(
void *,
const char*))
337 int optindex, handleoptions = 1, ret;
344 while (optindex < argc) {
345 opt = argv[optindex++];
347 if (handleoptions && opt[0] ==
'-' && opt[1] !=
'\0') {
348 if (opt[1] ==
'-' && opt[2] ==
'\0') {
354 if ((ret =
parse_option(optctx, opt, argv[optindex], options)) < 0)
358 if (parse_arg_function)
359 parse_arg_function(optctx, opt);
371 for (i = 0; i < g->
nb_opts; i++) {
377 "%s %s -- you are trying to apply an input option to an "
378 "output file or vice versa. Move this option before the "
379 "file it belongs to.\n", o->
key, o->
opt->
help,
403 for (i = 1; i < argc; i++) {
404 const char *cur_opt = argv[i];
406 if (*cur_opt++ !=
'-')
410 if (!po->
name && cur_opt[0] ==
'n' && cur_opt[1] ==
'o')
413 if ((!po->
name && !strcmp(cur_opt, optname)) ||
414 (po->
name && !strcmp(optname, po->
name)))
428 if (idx && argv[idx + 1])
432 #define FLAGS (o->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0
436 char opt_stripped[128];
439 #if CONFIG_AVRESAMPLE
446 if (!(p = strchr(opt,
':')))
447 p = opt + strlen(opt);
448 av_strlcpy(opt_stripped, opt,
FFMIN(
sizeof(opt_stripped), p - opt + 1));
452 ((opt[0] ==
'v' || opt[0] ==
'a' || opt[0] ==
's') &&
458 #if CONFIG_AVRESAMPLE
490 for (i = 0; i < nb_groups; i++) {
492 if (p->
sep && !strcmp(p->
sep, opt))
526 resample_opts =
NULL;
539 const char *key,
const char *val)
556 memset(octx, 0,
sizeof(*octx));
610 while (optindex < argc) {
611 const char *opt = argv[optindex++], *arg;
618 if (opt[0] !=
'-' || !opt[1]) {
625 #define GET_ARG(arg) \
627 arg = argv[optindex++]; \
629 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\
630 return AVERROR(EINVAL); \
639 groups[ret].
name, arg);
648 arg = argv[optindex++];
657 "argument '%s'.\n", po->
name, po->
help, arg);
662 if (argv[optindex]) {
666 "argument '%s'.\n", opt, argv[optindex]);
671 "with argument '%s'.\n", opt, argv[optindex]);
677 if (opt[0] ==
'n' && opt[1] ==
'o' &&
682 "argument 0.\n", po->
name, po->
help);
712 const struct {
const char *
name;
int level; } log_levels[] = {
727 if (!strcmp(log_levels[i].
name, arg)) {
733 level = strtol(arg, &tail, 10);
736 "Possible levels are numbers or:\n", arg);
749 struct rlimit rl = { lim, lim + 1 };
750 if (setrlimit(RLIMIT_CPU, &rl))
761 const char *errbuf_ptr = errbuf;
773 #define SHOW_VERSION 2
774 #define SHOW_CONFIG 4
776 #define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \
777 if (CONFIG_##LIBNAME) { \
778 const char *indent = flags & INDENT? " " : ""; \
779 if (flags & SHOW_VERSION) { \
780 unsigned int version = libname##_version(); \
781 av_log(NULL, level, \
782 "%slib%-10s %2d.%3d.%2d / %2d.%3d.%2d\n", \
784 LIB##LIBNAME##_VERSION_MAJOR, \
785 LIB##LIBNAME##_VERSION_MINOR, \
786 LIB##LIBNAME##_VERSION_MICRO, \
787 version >> 16, version >> 8 & 0xff, version & 0xff); \
789 if (flags & SHOW_CONFIG) { \
790 const char *cfg = libname##_configuration(); \
791 if (strcmp(LIBAV_CONFIGURATION, cfg)) { \
793 av_log(NULL, level, \
794 "%sWARNING: library configuration mismatch\n", \
798 av_log(NULL, level, "%s%-11s configuration: %s\n", \
799 indent, #libname, cfg); \
818 "%s version " LIBAV_VERSION ", Copyright (c) %d-%d the Libav developers\n",
840 "This version of %s has nonfree parts compiled in.\n"
841 "Therefore it is not legally redistributable.\n",
844 "%s is free software; you can redistribute it and/or modify\n"
845 "it under the terms of the GNU General Public License as published by\n"
846 "the Free Software Foundation; either version 3 of the License, or\n"
847 "(at your option) any later version.\n"
849 "%s is distributed in the hope that it will be useful,\n"
850 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
851 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
852 "GNU General Public License for more details.\n"
854 "You should have received a copy of the GNU General Public License\n"
855 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
858 "%s is free software; you can redistribute it and/or modify\n"
859 "it under the terms of the GNU General Public License as published by\n"
860 "the Free Software Foundation; either version 2 of the License, or\n"
861 "(at your option) any later version.\n"
863 "%s is distributed in the hope that it will be useful,\n"
864 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
865 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
866 "GNU General Public License for more details.\n"
868 "You should have received a copy of the GNU General Public License\n"
869 "along with %s; if not, write to the Free Software\n"
870 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
873 "%s is free software; you can redistribute it and/or modify\n"
874 "it under the terms of the GNU Lesser General Public License as published by\n"
875 "the Free Software Foundation; either version 3 of the License, or\n"
876 "(at your option) any later version.\n"
878 "%s is distributed in the hope that it will be useful,\n"
879 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
880 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
881 "GNU Lesser General Public License for more details.\n"
883 "You should have received a copy of the GNU Lesser General Public License\n"
884 "along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
887 "%s is free software; you can redistribute it and/or\n"
888 "modify it under the terms of the GNU Lesser General Public\n"
889 "License as published by the Free Software Foundation; either\n"
890 "version 2.1 of the License, or (at your option) any later version.\n"
892 "%s is distributed in the hope that it will be useful,\n"
893 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
894 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
895 "Lesser General Public License for more details.\n"
897 "You should have received a copy of the GNU Lesser General Public\n"
898 "License along with %s; if not, write to the Free Software\n"
899 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
911 const char *last_name;
913 printf(
"File formats:\n"
914 " D. = Demuxing supported\n"
915 " .E = Muxing supported\n"
922 const char *long_name =
NULL;
925 if ((!name || strcmp(ofmt->
name, name) < 0) &&
926 strcmp(ofmt->
name, last_name) > 0) {
933 if ((!name || strcmp(ifmt->
name, name) < 0) &&
934 strcmp(ifmt->
name, last_name) > 0) {
939 if (name && strcmp(ifmt->
name, name) == 0)
946 printf(
" %s%s %-15s %s\n",
950 long_name ? long_name:
" ");
955 #define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \
956 if (codec->field) { \
957 const type *p = c->field; \
959 printf(" Supported " list_name ":"); \
960 while (*p != term) { \
962 printf(" %s", name); \
972 printf(
"%s %s [%s]:\n", encoder ?
"Encoder" :
"Decoder", c->
name,
976 printf(
" Threading capabilities: ");
983 default: printf(
"no");
break;
991 printf(
" Supported framerates:");
993 printf(
" %d/%d", fps->
num, fps->
den);
1020 default:
return '?';
1028 if (prev->
id ==
id &&
1039 printf(
" (%s: ", encoder ?
"encoders" :
"decoders");
1042 printf(
"%s ", codec->
name);
1052 " D..... = Decoding supported\n"
1053 " .E.... = Encoding supported\n"
1054 " ..V... = Video codec\n"
1055 " ..A... = Audio codec\n"
1056 " ..S... = Subtitle codec\n"
1057 " ...I.. = Intra frame-only codec\n"
1058 " ....L. = Lossy compression\n"
1059 " .....S = Lossless compression\n"
1077 if (strcmp(codec->
name, desc->
name)) {
1084 if (strcmp(codec->
name, desc->
name)) {
1102 " S... = Subtitle\n"
1103 " .F.. = Frame-level multithreading\n"
1104 " ..S. = Slice-level multithreading\n"
1105 " ...X = Codec is experimental\n"
1107 encoder ?
"Encoders" :
"Decoders");
1118 if (strcmp(codec->
name, desc->
name))
1119 printf(
" (codec %s)", desc->
name);
1138 int show_bsfs(
void *optctx,
const char *opt,
const char *arg)
1142 printf(
"Bitstream filters:\n");
1144 printf(
"%s\n", bsf->
name);
1151 void *opaque =
NULL;
1154 printf(
"Supported file protocols:\n"
1157 printf(
"%s\n", name);
1158 printf(
"Output:\n");
1160 printf(
"%s\n", name);
1168 printf(
"Filters:\n");
1171 printf(
"%-16s %s\n",
filter->name,
filter->description);
1180 printf(
"Pixel formats:\n"
1181 "I.... = Supported Input format for conversion\n"
1182 ".O... = Supported Output format for conversion\n"
1183 "..H.. = Hardware accelerated format\n"
1184 "...P. = Paletted format\n"
1185 "....B = Bitstream format\n"
1186 "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n"
1190 # define sws_isSupportedInput(x) 0
1191 # define sws_isSupportedOutput(x) 0
1196 printf(
"%c%c%c%c%c %-16s %d %2d\n",
1243 "but no %s for it are available. Libav might need to be "
1244 "recompiled with additional external libraries.\n",
1245 name, encoder ?
"encoders" :
"decoders");
1265 printf(
" Common extensions: %s.\n", fmt->
extensions);
1284 printf(
" Common extensions: %s.\n", fmt->
extensions);
1286 printf(
" Mime type: %s.\n", fmt->
mime_type);
1289 printf(
" Default video codec: %s.\n", desc->
name);
1293 printf(
" Default audio codec: %s.\n", desc->
name);
1297 printf(
" Default subtitle codec: %s.\n", desc->
name);
1305 static void show_help_filter(
const char *
name)
1321 printf(
" slice threading supported\n");
1323 printf(
" Inputs:\n");
1325 for (i = 0; i < count; i++) {
1330 printf(
" dynamic (depending on the options)\n");
1332 printf(
" Outputs:\n");
1334 for (i = 0; i < count; i++) {
1339 printf(
" dynamic (depending on the options)\n");
1347 int show_help(
void *optctx,
const char *opt,
const char *arg)
1353 par = strchr(topic,
'=');
1359 }
else if (!strcmp(topic,
"decoder")) {
1361 }
else if (!strcmp(topic,
"encoder")) {
1363 }
else if (!strcmp(topic,
"demuxer")) {
1365 }
else if (!strcmp(topic,
"muxer")) {
1368 }
else if (!strcmp(topic,
"filter")) {
1369 show_help_filter(par);
1384 while (c !=
'\n' && c != EOF)
1393 FILE *f = fopen(filename,
"rb");
1400 fseek(f, 0, SEEK_END);
1402 fseek(f, 0, SEEK_SET);
1409 ret = fread(*bufptr, 1, *size, f);
1414 filename, strerror(errno));
1420 (*bufptr)[(*size)++] =
'\0';
1448 pts = reordered_pts;
1456 const char *preset_name,
int is_path,
1457 const char *codec_name)
1461 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
1466 av_strlcpy(filename, preset_name, filename_size);
1467 f = fopen(filename,
"r");
1469 for (i = 0; i < 3 && !f; i++) {
1472 snprintf(filename, filename_size,
"%s%s/%s.avpreset", base[i],
1473 i != 1 ?
"" :
"/.avconv", preset_name);
1474 f = fopen(filename,
"r");
1475 if (!f && codec_name) {
1476 snprintf(filename, filename_size,
1477 "%s%s/%s-%s.avpreset",
1478 base[i], i != 1 ?
"" :
"/.avconv", codec_name,
1480 f = fopen(filename,
"r");
1490 if (*spec <= '9' && *spec >=
'0')
1491 return strtol(spec,
NULL, 0) == st->
index;
1492 else if (*spec ==
'v' || *spec ==
'a' || *spec ==
's' || *spec ==
'd' ||
1506 if (*spec++ ==
':') {
1510 return i == st->
index;
1514 }
else if (*spec ==
'p' && *(spec + 1) ==
':') {
1518 prog_id = strtol(spec, &endptr, 0);
1523 if (*endptr++ ==
':') {
1524 int stream_idx = strtol(endptr,
NULL, 0);
1525 return stream_idx >= 0 &&
1535 }
else if (*spec ==
'i' && *(spec + 1) ==
':') {
1539 stream_id = strtol(spec, &endptr, 0);
1540 return stream_id == st->
id;
1541 }
else if (*spec ==
'm' && *(spec + 1) ==
':') {
1547 val = strchr(spec,
':');
1555 if (!val || !strcmp(tag->
value, val + 1))
1601 char *p = strchr(t->
key,
':');
1606 case 1: *p = 0;
break;
1608 default:
return NULL;
1616 else if (t->
key[0] == prefix &&
1638 "Could not alloc memory for stream options.\n");
1649 if (new_size >= INT_MAX / elem_size) {
1653 if (*size < new_size) {
1659 memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
1668 switch (media_type) {
1674 default:
return "unknown";
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
char * av_strndup(const char *s, size_t len) av_malloc_attrib
Duplicate a substring of the string s.
int64_t num_faulty_dts
Number of incorrect PTS values so far.
#define AV_CODEC_PROP_INTRA_ONLY
Codec uses only intra compression.
AVDictionary * resample_opts
Number of sample formats. DO NOT USE if linking dynamically.
int show_decoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the decoders supported by the program.
const char * name
< group name
struct SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
static void finish_group(OptionParseContext *octx, int group_idx, const char *arg)
int show_license(void *optctx, const char *opt, const char *arg)
Print the license of the program to stdout.
const AVClass * av_opt_child_class_next(const AVClass *parent, const AVClass *prev)
Iterate over potential AVOptions-enabled children of parent.
#define AV_CODEC_PROP_LOSSY
Codec supports lossy compression.
const char * name
Filter name.
#define AV_LOG_WARNING
Something somehow does not look correct.
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
const char * name
Name of the codec described by this descriptor.
void av_log_set_level(int level)
Set the log level.
int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, const OptionGroupDef *groups, int nb_groups)
Split the commandline into an intermediate form convenient for further processing.
void show_banner(void)
Print the program banner to stderr.
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int opt_loglevel(void *optctx, const char *opt, const char *arg)
Set the libav* libraries log level.
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
AVCodecContext * codec
Codec context associated with this stream.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
int index
stream index in AVFormatContext
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int show_protocols(void *optctx, const char *opt, const char *arg)
Print a listing containing all the protocols supported by the program.
const char * sep
Option to be used as group separator.
#define GET_CH_LAYOUT_DESC(ch_layout)
int64_t last_pts
Number of incorrect DTS values so far.
const AVFilter * avfilter_next(const AVFilter *prev)
Iterate over all registered filters.
int show_formats(void *optctx, const char *opt, const char *arg)
Print a listing containing all the formats supported by the program.
const char * description
A description of the filter.
int show_pix_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the pixel formats supported by the program.
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, AVCodec *codec)
Filter out options for given codec.
void init_pts_correction(PtsCorrectionContext *ctx)
Reset the state of the PtsCorrectionContext.
static void(* program_exit)(int ret)
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
int av_codec_is_decoder(const AVCodec *codec)
int av_codec_is_encoder(const AVCodec *codec)
unsigned int nb_stream_indexes
#define AV_LOG_QUIET
Print no output.
int show_codecs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the codecs supported by the program.
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
#define AV_OPT_FLAG_SUBTITLE_PARAM
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
Opaque data information usually continuous.
const AVFilterPad * inputs
List of inputs, terminated by a zeroed element.
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions...
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
#define AV_LOG_PANIC
Something went really wrong and we will crash now.
#define AV_CODEC_PROP_LOSSLESS
Codec supports lossless compression.
int id
Format-specific stream ID.
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
static void init_parse_context(OptionParseContext *octx, const OptionGroupDef *groups, int nb_groups)
const AVFilterPad * outputs
List of outputs, terminated by a zeroed element.
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
int flags
A combination of AVFILTER_FLAG_*.
#define AV_OPT_FLAG_VIDEO_PARAM
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
AVBitStreamFilter * av_bitstream_filter_next(const AVBitStreamFilter *f)
static void print_all_libs_info(int flags, int level)
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
#define AVFILTER_FLAG_DYNAMIC_OUTPUTS
The number of the filter outputs is not determined just by AVFilter.outputs.
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
static void print_codecs(int encoder)
int locate_option(int argc, char **argv, const OptionDef *options, const char *optname)
Return index of option opt in argv or 0 if not found.
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
AVDictionary * format_opts
const OptionDef options[]
int show_help(void *optctx, const char *opt, const char *arg)
Generic -h handler common to all avtools.
int flags
Option flags that must be set on each option that is applied to this group.
void show_help_default(const char *opt, const char *arg)
Per-avtool specific help handler.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
const AVClass * avresample_get_class(void)
Get the AVClass for AVAudioResampleContext.
const AVRational * supported_framerates
array of supported framerates, or NULL if any, array is terminated by {0,0}
#define AV_OPT_FLAG_AUDIO_PARAM
int show_sample_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the sample formats supported by the program.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
#define sws_isSupportedOutput(x)
int capabilities
Codec capabilities.
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
static void show_help_muxer(const char *name)
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name)
AVPixelFormat
Pixel format.
int show_filters(void *optctx, const char *opt, const char *arg)
Print a listing containing all the filters supported by the program.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc.
static const OptionDef * find_option(const OptionDef *po, const char *name)
int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int64_t dts)
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect time...
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
uint8_t nb_components
The number of components each pixel has, (1-4)
const char * media_type_string(enum AVMediaType media_type)
Get a string describing a media type.
void * av_realloc(void *ptr, size_t size) 1(2)
Allocate or reallocate a block of memory.
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int show_bsfs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the bit stream filters supported by the program.
AVStream ** streams
A list of all streams in the file.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static void print_codecs_for_id(enum AVCodecID id, int encoder)
#define GET_PIX_FMT_NAME(pix_fmt)
const OptionGroupDef * group_def
A list of option groups that all have the same group type (e.g.
#define FF_ARRAY_ELEMS(a)
void sws_freeContext(struct SwsContext *swsContext)
Free the swscaler context swsContext.
AVDictionary * resample_opts
#define sws_isSupportedInput(x)
static const OptionGroupDef groups[]
Opaque data information usually sparse.
enum AVPixelFormat pix_fmt
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
#define GET_SAMPLE_FMT_NAME(sample_fmt)
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
static char get_media_type_char(enum AVMediaType type)
AVCodec * av_codec_next(const AVCodec *c)
If c is NULL, returns the first registered codec, if c is non-NULL, returns the next registered codec...
#define GET_SAMPLE_RATE_NAME(rate)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
int(* func_arg)(void *, const char *, const char *)
#define AV_LOG_INFO
Standard information.
static const AVCodec * next_codec_for_id(enum AVCodecID id, const AVCodec *prev, int encoder)
enum AVMediaType codec_type
const char * long_name
Descriptive name for the codec, meant to be more human readable than name.
AVSampleFormat
Audio Sample Formats.
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
const AVCodecDescriptor * avcodec_descriptor_next(const AVCodecDescriptor *prev)
Iterate over all codec descriptors known to libavcodec.
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
const int program_birth_year
program birth year, defined by the program for show_banner()
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
FILE * get_preset_file(char *filename, size_t filename_size, const char *preset_name, int is_path, const char *codec_name)
Get a file corresponding to a preset file.
const OptionGroupDef * group_def
#define PRINT_LIB_INFO(libname, LIBNAME, flags, level)
Describe the class of an AVClass context structure.
rational number numerator/denominator
const char program_name[]
program name, defined by the program for show_version().
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
Parse a string specifying a time and return its corresponding value as a number of microseconds...
void * grow_array(void *array, int elem_size, int *size, int new_size)
Realloc array to hold new_size elements of elem_size.
struct SwsContext * sws_opts
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int64_t last_dts
PTS of the last frame.
static void print_codec(const AVCodec *c)
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
This struct describes the properties of a single codec described by an AVCodecID. ...
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
Parse a string and return its corresponding value as a double.
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
Read the file with name filename, and put its content in a newly allocated 0-terminated buffer...
AVInputFormat * av_iformat_next(const AVInputFormat *f)
If f is NULL, returns the first registered input format, if f is non-NULL, returns the next registere...
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
static int match_group_separator(const OptionGroupDef *groups, int nb_groups, const char *opt)
static int swscale(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[])
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
An option extracted from the commandline.
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
static const int this_year
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
AVDictionary * codec_opts
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
AVDictionary * format_opts
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
AVOutputFormat * av_oformat_next(const AVOutputFormat *f)
If f is NULL, returns the first registered output format, if f is non-NULL, returns the next register...
#define CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void av_set_cpu_flags_mask(int mask)
Set a mask on flags returned by av_get_cpu_flags().
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required poi...
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
struct AVOutputFormat * oformat
The output container format.
#define GROW_ARRAY(array, nb_elems)
#define AVERROR_OPTION_NOT_FOUND
Option not found.
char * av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt)
Generate a string corresponding to the sample format with sample_fmt, or a header if sample_fmt is ne...
const AVClass * priv_class
A class for the private data, used to declare filter private AVOptions.
int av_parse_cpu_flags(const char *s)
Parse CPU flags from a string.
AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
const AVClass * priv_class
AVClass for the private context.
static int write_option(void *optctx, const OptionDef *po, const char *opt, const char *arg)
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
int avfilter_pad_count(const AVFilterPad *pads)
Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
int opt_cpuflags(void *optctx, const char *opt, const char *arg)
Override the cpuflags mask.
AVDictionary * codec_opts
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0...
#define AV_DICT_IGNORE_SUFFIX
static void show_help_demuxer(const char *name)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int show_version(void *optctx, const char *opt, const char *arg)
Print the version of the program to stdout.
AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
struct SwsContext * sws_opts
unsigned int * stream_index
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
const char * long_name
A more descriptive name for this codec.
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
static void show_help_codec(const char *name, int encoder)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int show_encoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the encoders supported by the program.
static void add_opt(OptionParseContext *octx, const OptionDef *opt, const char *key, const char *val)