22 #ifndef FFMPEG_CMDUTILS_H
23 #define FFMPEG_CMDUTILS_H
27 #include "libavcodec/avcodec.h"
28 #include "libavfilter/avfilter.h"
29 #include "libavformat/avformat.h"
30 #include "libswscale/swscale.h"
106 int opt_opencl(
void *optctx,
const char *opt,
const char *
arg);
127 double min,
double max);
160 #define HAS_ARG 0x0001
161 #define OPT_BOOL 0x0002
162 #define OPT_EXPERT 0x0004
163 #define OPT_STRING 0x0008
164 #define OPT_VIDEO 0x0010
165 #define OPT_AUDIO 0x0020
166 #define OPT_INT 0x0080
167 #define OPT_FLOAT 0x0100
168 #define OPT_SUBTITLE 0x0200
169 #define OPT_INT64 0x0400
170 #define OPT_EXIT 0x0800
171 #define OPT_DATA 0x1000
172 #define OPT_PERFILE 0x2000
174 #define OPT_OFFSET 0x4000
175 #define OPT_SPEC 0x8000
178 #define OPT_TIME 0x10000
179 #define OPT_DOUBLE 0x20000
180 #define OPT_INPUT 0x40000
181 #define OPT_OUTPUT 0x80000
184 int (*
func_arg)(
void *,
const char *,
const char *);
201 int rej_flags,
int alt_flags);
218 int show_help(
void *optctx,
const char *opt,
const char *
arg);
233 void (* parse_arg_function)(
void *optctx,
const char*));
347 const char *optname);
462 int show_bsfs(
void *optctx,
const char *opt,
const char *
arg);
534 const char *preset_name,
int is_path,
const char *codec_name);
546 void *
grow_array(
void *array,
int elem_size,
int *
size,
int new_size);
548 #define media_type_string av_get_media_type_string
550 #define GROW_ARRAY(array, nb_elems)\
551 array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
553 #define GET_PIX_FMT_NAME(pix_fmt)\
554 const char *name = av_get_pix_fmt_name(pix_fmt);
556 #define GET_SAMPLE_FMT_NAME(sample_fmt)\
557 const char *name = av_get_sample_fmt_name(sample_fmt)
559 #define GET_SAMPLE_RATE_NAME(rate)\
561 snprintf(name, sizeof(name), "%d", rate);
563 #define GET_CH_LAYOUT_NAME(ch_layout)\
565 snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
567 #define GET_CH_LAYOUT_DESC(ch_layout)\
569 av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
int opt_codec_debug(void *optctx, const char *opt, const char *arg)
AVDictionary * resample_opts
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
int show_license(void *optctx, const char *opt, const char *arg)
Print the license of the program to stdout.
int(* func_arg)(void *, const char *, const char *)
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.
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.
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
int show_protocols(void *optctx, const char *opt, const char *arg)
Print a listing containing all the protocols supported by the program.
AVCodecContext * avcodec_opts[AVMEDIA_TYPE_NB]
const char * sep
Option to be used as group separator.
int show_formats(void *optctx, const char *opt, const char *arg)
Print a listing containing all the formats supported by the program.
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 uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
int show_codecs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the codecs supported by the program.
static double cb(void *priv, double x, double y)
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.
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...
static const OptionGroupDef groups[]
int opt_max_alloc(void *optctx, const char *opt, const char *arg)
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, void(*parse_arg_function)(void *, const char *))
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
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 OptionDef options[]
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
int show_help(void *optctx, const char *opt, const char *arg)
Generic -h handler common to all fftools.
int flags
Option flags that must be set on each option that is applied to this group.
AVCodecID
Identify the syntax and semantics of the bitstream.
int show_sample_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the sample formats supported by the program.
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
int show_filters(void *optctx, const char *opt, const char *arg)
Print a listing containing all the filters supported by the program.
int opt_report(const char *opt)
const int program_birth_year
program birth year, defined by the program for show_banner()
int opt_opencl(void *optctx, const char *opt, const char *arg)
int show_bsfs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the bit stream filters supported by the program.
const OptionGroupDef * group_def
A list of option groups that all have the same group type (e.g.
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
AVDictionary * resample_opts
char * specifier
stream/chapter/program/...
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
main external API structure.
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
Describe the class of an AVClass context structure.
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
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...
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...
const int this_year
this year, defined by the program for show_banner()
AVDictionary * codec_opts
AVDictionary * format_opts
AVFormatContext * avformat_opts
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
void 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_layouts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the standard channel layouts supported by the program.
int opt_cpuflags(void *optctx, const char *opt, const char *arg)
Override the cpuflags.
AVDictionary * codec_opts
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0...
int show_version(void *optctx, const char *opt, const char *arg)
Print the version of the program to stdout.
struct SwsContext * sws_opts
const char program_name[]
program name, defined by the program for show_version().
int show_encoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the encoders supported by the program.