Go to the documentation of this file.
22 #ifndef FFTOOLS_CMDUTILS_H
23 #define FFTOOLS_CMDUTILS_H
107 int opt_report(
void *optctx,
const char *opt,
const char *
arg);
166 #define HAS_ARG 0x0001
167 #define OPT_BOOL 0x0002
168 #define OPT_EXPERT 0x0004
169 #define OPT_STRING 0x0008
170 #define OPT_VIDEO 0x0010
171 #define OPT_AUDIO 0x0020
172 #define OPT_INT 0x0080
173 #define OPT_FLOAT 0x0100
174 #define OPT_SUBTITLE 0x0200
175 #define OPT_INT64 0x0400
176 #define OPT_EXIT 0x0800
177 #define OPT_DATA 0x1000
178 #define OPT_PERFILE 0x2000
180 #define OPT_OFFSET 0x4000
181 #define OPT_SPEC 0x8000
184 #define OPT_TIME 0x10000
185 #define OPT_DOUBLE 0x20000
186 #define OPT_INPUT 0x40000
187 #define OPT_OUTPUT 0x80000
207 int rej_flags,
int alt_flags);
210 #define CMDUTILS_COMMON_OPTIONS_AVDEVICE \
211 { "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \
212 "list sources of the input device", "device" }, \
213 { "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \
214 "list sinks of the output device", "device" }, \
217 #define CMDUTILS_COMMON_OPTIONS_AVDEVICE
220 #define CMDUTILS_COMMON_OPTIONS \
221 { "L", OPT_EXIT, { .func_arg = show_license }, "show license" }, \
222 { "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
223 { "?", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
224 { "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
225 { "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
226 { "version", OPT_EXIT, { .func_arg = show_version }, "show version" }, \
227 { "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" }, \
228 { "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" }, \
229 { "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \
230 { "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \
231 { "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \
232 { "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \
233 { "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" }, \
234 { "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" }, \
235 { "bsfs", OPT_EXIT, { .func_arg = show_bsfs }, "show available bit stream filters" }, \
236 { "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" }, \
237 { "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" }, \
238 { "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" }, \
239 { "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" }, \
240 { "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" }, \
241 { "dispositions", OPT_EXIT, { .func_arg = show_dispositions}, "show available stream dispositions" }, \
242 { "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" }, \
243 { "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
244 { "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
245 { "report", 0, { .func_arg = opt_report }, "generate a report" }, \
246 { "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" }, \
247 { "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, \
248 { "cpucount", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpucount }, "force specific cpu count", "count" }, \
249 { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, \
250 CMDUTILS_COMMON_OPTIONS_AVDEVICE \
267 int show_help(
void *optctx,
const char *opt,
const char *
arg);
282 void (* parse_arg_function)(
void *optctx,
const char*));
395 const char *optname);
512 int show_sinks(
void *optctx,
const char *opt,
const char *
arg);
518 int show_sources(
void *optctx,
const char *opt,
const char *
arg);
552 int show_bsfs(
void *optctx,
const char *opt,
const char *
arg);
617 const char *preset_name,
int is_path,
const char *codec_name);
645 #define media_type_string av_get_media_type_string
647 #define GROW_ARRAY(array, nb_elems)\
648 array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
650 #define ALLOC_ARRAY_ELEM(array, nb_elems)\
651 allocate_array_elem(&array, sizeof(*array[0]), &nb_elems)
653 #define GET_PIX_FMT_NAME(pix_fmt)\
654 const char *name = av_get_pix_fmt_name(pix_fmt);
656 #define GET_CODEC_NAME(id)\
657 const char *name = avcodec_descriptor_get(id)->name;
659 #define GET_SAMPLE_FMT_NAME(sample_fmt)\
660 const char *name = av_get_sample_fmt_name(sample_fmt)
662 #define GET_SAMPLE_RATE_NAME(rate)\
664 snprintf(name, sizeof(name), "%d", rate);
666 #define GET_CH_LAYOUT_NAME(ch_layout)\
668 snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
670 #define GET_CH_LAYOUT_DESC(ch_layout)\
672 av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
const OptionGroupDef * group_def
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
static double cb(void *priv, double x, double y)
double get_rotation(int32_t *displaymatrix)
const char program_name[]
program name, defined by the program for show_version().
AVDictionary * codec_opts
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
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.
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.
A list of option groups that all have the same group type (e.g.
An option extracted from the commandline.
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.
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 OptionGroupDef * group_def
int show_layouts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the standard channel layouts supported by the program.
AVCodecContext * avcodec_opts[AVMEDIA_TYPE_NB]
AVDictionary * codec_opts
int flags
Option flags that must be set on each option that is applied to this group.
void * grow_array(void *array, int elem_size, int *size, int new_size)
Realloc array to hold new_size elements of elem_size.
char * specifier
stream/chapter/program/...
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
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...
void * allocate_array_elem(void *array, size_t elem_size, int *nb_elems)
Atomically add a new element to an array of pointers, i.e.
void init_dynload(void)
Initialize dynamic library loading.
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *optctx, const char *))
Parse the command line arguments.
const char * name
< group name
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
AVDictionary * format_opts
Describe the class of an AVClass context structure.
int show_encoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the encoders supported by the program.
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec)
Filter out options for given codec.
int show_version(void *optctx, const char *opt, const char *arg)
Print the version of the program to stdout.
int show_pix_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the pixel formats supported by the program.
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
AVCodecID
Identify the syntax and semantics of the bitstream.
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0.
int show_license(void *optctx, const char *opt, const char *arg)
Print the license of the program to stdout.
const OptionDef options[]
int opt_codec_debug(void *optctx, const char *opt, const char *arg)
int show_demuxers(void *optctx, const char *opt, const char *arg)
Print a listing containing all the demuxer supported by the program (including devices).
int opt_cpuflags(void *optctx, const char *opt, const char *arg)
Override the cpuflags.
int show_devices(void *optctx, const char *opt, const char *arg)
Print a listing containing all the devices supported by the program.
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
void exit_program(int ret) av_noreturn
Wraps exit with a program-specific cleanup routine.
int show_decoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the decoders supported by the program.
int opt_loglevel(void *optctx, const char *opt, const char *arg)
Set the libav* libraries log level.
int opt_max_alloc(void *optctx, const char *opt, const char *arg)
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
int show_muxers(void *optctx, const char *opt, const char *arg)
Print a listing containing all the muxers supported by the program (including devices).
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.
AVDictionary * format_opts
int show_protocols(void *optctx, const char *opt, const char *arg)
Print a listing containing all the protocols supported by the program.
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.
static int array[MAX_W *MAX_W]
int show_help(void *optctx, const char *opt, const char *arg)
Generic -h handler common to all fftools.
main external API structure.
int show_formats(void *optctx, const char *opt, const char *arg)
Print a listing containing all the formats supported by the program (including devices).
int show_colors(void *optctx, const char *opt, const char *arg)
Print a listing containing all the color names and values recognized by the program.
int show_codecs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the codecs supported by the program.
int show_filters(void *optctx, const char *opt, const char *arg)
Print a listing containing all the filters supported by the program.
int show_buildconf(void *optctx, const char *opt, const char *arg)
Print the build configuration of the program to stdout.
int show_dispositions(void *optctx, const char *opt, const char *arg)
Print a listing containing all supported stream dispositions.
int show_sample_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the sample formats supported by the program.
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
const char * sep
Option to be used as group separator.
int show_bsfs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the bit stream filters supported by the program.
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
#define flags(name, subs,...)
int opt_report(void *optctx, const char *opt, const char *arg)
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
AVFormatContext * avformat_opts
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.
int opt_cpucount(void *optctx, const char *opt, const char *arg)
Override the cpucount.
int(* func_arg)(void *, const char *, const char *)
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.
const int program_birth_year
program birth year, defined by the program for show_banner()