Go to the documentation of this file.
74 vfprintf(stdout, fmt, vl);
79 #if HAVE_SETDLLDIRECTORY && defined(_WIN32)
108 error =
"Expected number for %s but found: %s\n";
109 else if (d < min || d >
max)
110 error =
"The value for %s was %s which is not within %f - %f\n";
112 error =
"Expected int64 for %s but found %s\n";
114 error =
"Expected int for %s but found %s\n";
128 is_duration ?
"duration" :
"date",
context, timestr);
135 int rej_flags,
int alt_flags)
144 if (((po->
flags & req_flags) != req_flags) ||
145 (alt_flags && !(po->
flags & alt_flags)) ||
146 (po->
flags & rej_flags))
190 #if HAVE_COMMANDLINETOARGVW && defined(_WIN32)
191 #include <shellapi.h>
193 static char** win32_argv_utf8 =
NULL;
194 static int win32_argc = 0;
207 int i, buffsize = 0,
offset = 0;
209 if (win32_argv_utf8) {
210 *argc_ptr = win32_argc;
211 *argv_ptr = win32_argv_utf8;
216 argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc);
217 if (win32_argc <= 0 || !argv_w)
221 for (
i = 0;
i < win32_argc;
i++)
222 buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[
i], -1,
225 win32_argv_utf8 =
av_mallocz(
sizeof(
char *) * (win32_argc + 1) + buffsize);
226 argstr_flat = (
char *)win32_argv_utf8 +
sizeof(
char *) * (win32_argc + 1);
227 if (!win32_argv_utf8) {
232 for (
i = 0;
i < win32_argc;
i++) {
233 win32_argv_utf8[
i] = &argstr_flat[
offset];
234 offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[
i], -1,
238 win32_argv_utf8[
i] =
NULL;
241 *argc_ptr = win32_argc;
242 *argv_ptr = win32_argv_utf8;
262 char *p = strchr(opt,
':');
265 dstcount = (
int *)(so + 1);
266 *so =
grow_array(*so,
sizeof(**so), dstcount, *dstcount + 1);
270 (*so)[*dstcount - 1].specifier =
str;
271 dst = &(*so)[*dstcount - 1].u;
295 "Failed to set value '%s' for option '%s': %s\n",
310 .
name =
"AVOption passthrough",
319 if (!po->
name && opt[0] ==
'n' && opt[1] ==
'o') {
346 void (*parse_arg_function)(
void *,
const char*))
349 int optindex, handleoptions = 1,
ret;
356 while (optindex < argc) {
357 opt = argv[optindex++];
359 if (handleoptions && opt[0] ==
'-' && opt[1] !=
'\0') {
360 if (opt[1] ==
'-' && opt[2] ==
'\0') {
370 if (parse_arg_function)
371 parse_arg_function(optctx, opt);
381 g->group_def->name,
g->arg);
383 for (
i = 0;
i <
g->nb_opts;
i++) {
386 if (
g->group_def->flags &&
387 !(
g->group_def->flags & o->
opt->
flags)) {
389 "%s %s -- you are trying to apply an input option to an "
390 "output file or vice versa. Move this option before the "
391 "file it belongs to.\n", o->
key, o->
opt->
help,
392 g->group_def->name,
g->arg);
415 for (
i = 1;
i < argc;
i++) {
416 const char *cur_opt = argv[
i];
418 if (*cur_opt++ !=
'-')
422 if (!po->
name && cur_opt[0] ==
'n' && cur_opt[1] ==
'o')
425 if ((!po->
name && !strcmp(cur_opt, optname)) ||
426 (po->
name && !strcmp(optname, po->
name)))
437 const unsigned char *p;
440 if (!((*p >=
'+' && *p <=
':') || (*p >=
'@' && *p <=
'Z') ||
441 *p ==
'_' || (*p >=
'a' && *p <=
'z')))
448 for (p =
a; *p; p++) {
449 if (*p ==
'\\' || *p ==
'"' || *p ==
'$' || *p ==
'`')
451 else if (*p < ' ' || *p >
'~')
477 if (idx && argv[idx + 1])
487 for (
i = 0;
i < argc;
i++) {
501 int opt_flags,
int search_flags)
509 #define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0
514 char opt_stripped[128];
520 #if CONFIG_SWRESAMPLE
524 if (!strcmp(opt,
"debug") || !strcmp(opt,
"fdebug"))
527 if (!(p = strchr(opt,
':')))
528 p = opt + strlen(opt);
529 av_strlcpy(opt_stripped, opt,
FFMIN(
sizeof(opt_stripped), p - opt + 1));
533 ((opt[0] ==
'v' || opt[0] ==
'a' || opt[0] ==
's') &&
548 if (!strcmp(opt,
"srcw") || !strcmp(opt,
"srch") ||
549 !strcmp(opt,
"dstw") || !strcmp(opt,
"dsth") ||
550 !strcmp(opt,
"src_format") || !strcmp(opt,
"dst_format")) {
551 av_log(
NULL,
AV_LOG_ERROR,
"Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n");
559 if (!consumed && !strcmp(opt,
"sws_flags")) {
564 #if CONFIG_SWRESAMPLE
587 for (
i = 0;
i < nb_groups;
i++) {
589 if (p->
sep && !strcmp(p->
sep, opt))
631 const char *
key,
const char *
val)
637 g->opts[
g->nb_opts - 1].opt = opt;
638 g->opts[
g->nb_opts - 1].key =
key;
639 g->opts[
g->nb_opts - 1].val =
val;
648 memset(octx, 0,
sizeof(*octx));
700 while (optindex < argc) {
701 const char *opt = argv[optindex++], *
arg;
707 if (opt[0] ==
'-' && opt[1] ==
'-' && !opt[2]) {
712 if (opt[0] !=
'-' || !opt[1] || dashdash+1 == optindex) {
719 #define GET_ARG(arg) \
721 arg = argv[optindex++]; \
723 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\
724 return AVERROR(EINVAL); \
742 arg = argv[optindex++];
756 if (argv[optindex]) {
760 "argument '%s'.\n", opt, argv[optindex]);
765 "with argument '%s'.\n", opt, argv[optindex]);
771 if (opt[0] ==
'n' && opt[1] ==
'o' &&
776 "argument 0.\n", po->
name, po->
help);
786 "command: may be ignored.\n");
796 const char *errbuf_ptr = errbuf;
808 while (
c !=
'\n' &&
c != EOF)
815 const char *preset_name,
int is_path,
816 const char *codec_name)
820 #if HAVE_GETMODULEHANDLE && defined(_WIN32)
821 char *datadir =
NULL;
824 char *env_ffmpeg_datadir =
getenv_utf8(
"FFMPEG_DATADIR");
825 const char *
base[3] = { env_ffmpeg_datadir,
830 av_strlcpy(filename, preset_name, filename_size);
833 #if HAVE_GETMODULEHANDLE && defined(_WIN32)
834 wchar_t *datadir_w = get_module_filename(
NULL);
837 if (wchartoutf8(datadir_w, &datadir))
844 for (ls = datadir; *ls; ls++)
845 if (*ls ==
'\\') *ls =
'/';
847 if (ls = strrchr(datadir,
'/'))
849 ptrdiff_t datadir_len = ls - datadir;
850 size_t desired_size = datadir_len + strlen(
"/ffpresets") + 1;
852 datadir, desired_size,
sizeof *datadir);
854 datadir = new_datadir;
855 datadir[datadir_len] = 0;
856 strncat(datadir,
"/ffpresets", desired_size - 1 - datadir_len);
862 for (
i = 0;
i < 3 && !
f;
i++) {
865 snprintf(filename, filename_size,
"%s%s/%s.ffpreset",
base[
i],
866 i != 1 ?
"" :
"/.ffmpeg", preset_name);
868 if (!
f && codec_name) {
870 "%s%s/%s-%s.ffpreset",
871 base[
i],
i != 1 ?
"" :
"/.ffmpeg", codec_name,
878 #if HAVE_GETMODULEHANDLE && defined(_WIN32)
925 char *p = strchr(t->
key,
':');
930 case 1: *p = 0;
break;
941 else if (t->
key[0] == prefix &&
963 "Could not alloc memory for stream options.\n");
966 for (
i = 0;
i <
s->nb_streams;
i++)
974 if (new_size >= INT_MAX / elem_size) {
978 if (*
size < new_size) {
984 memset(
tmp + *
size*elem_size, 0, (new_size-*
size) * elem_size);
1009 theta -= 360*
floor(theta/360 + 0.9/360);
1011 if (
fabs(theta - 90*
round(theta/90)) > 2)
1013 "If you want to help, upload a sample "
1014 "of this file to https://streams.videolan.org/upload/ "
1015 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)");
static void error(const char *err)
static FILE * fopen_utf8(const char *path, const char *mode)
const OptionGroupDef * group_def
#define AV_LOG_WARNING
Something somehow does not look correct.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AV_OPT_FLAG_VIDEO_PARAM
enum AVMediaType codec_type
General type of the encoded data.
static double cb(void *priv, double x, double y)
const AVClass * priv_class
AVClass for the private context.
static void init_parse_context(OptionParseContext *octx, const OptionGroupDef *groups, int nb_groups)
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
int init_report(const char *env, FILE **file)
AVDictionary * format_opts
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define AV_LOG_VERBOSE
Detailed information.
static void freeenv_utf8(char *var)
#define fc(width, name, range_min, range_max)
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
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.
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...
A list of option groups that all have the same group type (e.g.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
An option extracted from the commandline.
static double val(void *priv, double ch)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
#define us(width, name, range_min, range_max, subs,...)
const OptionGroupDef * group_def
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * codec_opts
static void check_options(const OptionDef *po)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static FILE * report_file
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.
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
static __device__ float floor(float a)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
#define AV_OPT_FLAG_AUDIO_PARAM
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.
static void finish_group(OptionParseContext *octx, int group_idx, const char *arg)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your context
void init_dynload(void)
Initialize dynamic library loading.
AVDictionary * format_opts
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Describe the class of an AVClass context structure.
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
static __device__ float fabs(float a)
static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
int opt_loglevel(void *optctx, const char *opt, const char *arg)
Set the libav* libraries log level.
static char * getenv_utf8(const char *varname)
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
static int write_option(void *optctx, const OptionDef *po, const char *opt, const char *arg)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#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 poin...
AVCodecID
Identify the syntax and semantics of the bitstream.
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
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 * codec_opts
const OptionDef options[]
int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the stream st contained in s is matched by the stream specifier spec.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
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.
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
printf("static const uint8_t my_array[100] = {\n")
void * allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
Atomically add a new element to an array of pointers, i.e.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
static void(* program_exit)(int ret)
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
void av_log_set_level(int level)
Set the log level.
#define i(width, name, range_min, range_max)
static av_always_inline av_const double round(double x)
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec)
Filter out options for given codec.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * av_calloc(size_t nmemb, size_t size)
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
static int array[MAX_W *MAX_W]
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0.
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
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,...
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
static void add_opt(OptionParseContext *octx, const OptionDef *opt, const char *key, const char *val)
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
const AVClass * av_opt_child_class_iterate(const AVClass *parent, void **iter)
Iterate over potential AVOptions-enabled children of parent.
#define GROW_ARRAY(array, nb_elems)
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.
char * av_strdup(const char *s)
Duplicate a string.
#define AV_OPT_FLAG_SUBTITLE_PARAM
const char * sep
Option to be used as group separator.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
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.
#define flags(name, subs,...)
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.
static const OptionDef * find_option(const OptionDef *po, const char *name)
double get_rotation(int32_t *displaymatrix)
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.
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
static void dump_argument(FILE *report_file, const char *a)
static int match_group_separator(const OptionGroupDef *groups, int nb_groups, const char *opt)
int(* func_arg)(void *, const char *, const char *)
static const AVOption * opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.