22 #ifndef LIBAV_CMDUTILS_H
23 #define LIBAV_CMDUTILS_H
68 int opt_default(
void *optctx,
const char *opt,
const char *arg);
73 int opt_loglevel(
void *optctx,
const char *opt,
const char *arg);
78 int opt_timelimit(
void *optctx,
const char *opt,
const char *arg);
94 double min,
double max);
127 #define HAS_ARG 0x0001
128 #define OPT_BOOL 0x0002
129 #define OPT_EXPERT 0x0004
130 #define OPT_STRING 0x0008
131 #define OPT_VIDEO 0x0010
132 #define OPT_AUDIO 0x0020
133 #define OPT_INT 0x0080
134 #define OPT_FLOAT 0x0100
135 #define OPT_SUBTITLE 0x0200
136 #define OPT_INT64 0x0400
137 #define OPT_EXIT 0x0800
138 #define OPT_DATA 0x1000
139 #define OPT_PERFILE 0x2000
141 #define OPT_OFFSET 0x4000
142 #define OPT_SPEC 0x8000
145 #define OPT_TIME 0x10000
146 #define OPT_DOUBLE 0x20000
149 int (*
func_arg)(
void *,
const char *,
const char *);
166 int rej_flags,
int alt_flags);
183 int show_help(
void *optctx,
const char *opt,
const char *arg);
198 void (* parse_arg_function)(
void *optctx,
const char*));
205 int parse_option(
void *optctx,
const char *opt,
const char *arg,
305 const char *optname);
372 int show_version(
void *optctx,
const char *opt,
const char *arg);
378 int show_license(
void *optctx,
const char *opt,
const char *arg);
384 int show_formats(
void *optctx,
const char *opt,
const char *arg);
390 int show_codecs(
void *optctx,
const char *opt,
const char *arg);
396 int show_decoders(
void *optctx,
const char *opt,
const char *arg);
402 int show_encoders(
void *optctx,
const char *opt,
const char *arg);
408 int show_filters(
void *optctx,
const char *opt,
const char *arg);
414 int show_bsfs(
void *optctx,
const char *opt,
const char *arg);
420 int show_protocols(
void *optctx,
const char *opt,
const char *arg);
426 int show_pix_fmts(
void *optctx,
const char *opt,
const char *arg);
495 const char *preset_name,
int is_path,
const char *codec_name);
507 void *
grow_array(
void *array,
int elem_size,
int *
size,
int new_size);
509 #define GROW_ARRAY(array, nb_elems)\
510 array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
555 #define GET_PIX_FMT_NAME(pix_fmt)\
556 const char *name = av_get_pix_fmt_name(pix_fmt);
558 #define GET_SAMPLE_FMT_NAME(sample_fmt)\
559 const char *name = av_get_sample_fmt_name(sample_fmt)
561 #define GET_SAMPLE_RATE_NAME(rate)\
563 snprintf(name, sizeof(name), "%d", rate);
565 #define GET_CH_LAYOUT_NAME(ch_layout)\
567 snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
569 #define GET_CH_LAYOUT_DESC(ch_layout)\
571 av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
int64_t num_faulty_dts
Number of incorrect PTS values so far.
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 show_bsfs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the bit stream filters supported by the program.
struct OptionParseContext OptionParseContext
This structure describes decoded (raw) audio or video data.
int show_pix_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the pixel formats supported by the program.
const char * name
< group name
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
int(* func_arg)(void *, const char *, const char *)
struct OptionDef OptionDef
AVCodecContext * avcodec_opts[AVMEDIA_TYPE_NB]
const char * sep
Option to be used as group separator.
A reference-counted buffer data type used by the filter system.
int64_t last_pts
Number of incorrect DTS values so far.
int show_decoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the decoders supported by the program.
AVDictionary * format_opts
struct FrameBuffer * next
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 opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
int show_protocols(void *optctx, const char *opt, const char *arg)
Print a listing containing all the protocols supported by the program.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
struct OptionGroupDef OptionGroupDef
int codec_get_buffer(AVCodecContext *s, AVFrame *frame)
Get a frame from the pool.
external api for the swscale stuff
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
int show_license(void *optctx, const char *opt, const char *arg)
Print the license of the program to stdout.
AVCodecID
Identify the syntax and semantics of the bitstream.
struct SwsContext * sws_opts
void filter_release_buffer(AVFilterBuffer *fb)
A callback to be used for AVFilterBuffer.free.
void init_opts(void)
Initialize the cmdutils option system, in particular allocate the *_opts contexts.
void free_buffer_pool(FrameBuffer **pool)
Free all the buffers in the pool.
void codec_release_buffer(AVCodecContext *s, AVFrame *frame)
A callback to be used for AVCodecContext.release_buffer along with codec_get_buffer().
const int program_birth_year
program birth year, defined by the program for show_banner()
enum AVPixelFormat pix_fmt
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
void init_pts_correction(PtsCorrectionContext *ctx)
Reset the state of the PtsCorrectionContext.
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-avtool specific help handler.
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.
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
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 * specifier
stream/chapter/program/...
struct OptionGroupList OptionGroupList
A list of option groups that all have the same group type (e.g.
static const OptionGroupDef groups[]
struct FrameBuffer FrameBuffer
void show_banner(void)
Print the program banner to stderr.
struct OptionGroup OptionGroup
int opt_loglevel(void *optctx, const char *opt, const char *arg)
Set the libav* libraries log level.
struct PtsCorrectionContext PtsCorrectionContext
int show_version(void *optctx, const char *opt, const char *arg)
Print the version of the program to stdout.
int show_formats(void *optctx, const char *opt, const char *arg)
Print a listing containing all the formats supported by the program.
struct FrameBuffer ** pool
head of the buffer pool
main external API 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...
AVDictionary * codec_opts
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, AVCodec *codec)
Filter out options for given codec.
const OptionGroupDef * group_def
Describe the class of an AVClass context structure.
static OutputContext octx
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...
int show_codecs(void *optctx, const char *opt, const char *arg)
Print a listing containing all the codecs supported by the program.
struct SpecifierOpt SpecifierOpt
int64_t last_dts
PTS of the last frame.
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 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 OptionDef options[]
An option extracted from the commandline.
int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t pts, int64_t dts)
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect time...
AVDictionary * format_opts
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.
AVFormatContext * avformat_opts
void * grow_array(void *array, int elem_size, int *size, int new_size)
Realloc array to hold new_size elements of elem_size.
int show_encoders(void *optctx, const char *opt, const char *arg)
Print a listing containing all the encoders supported by the program.
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
int show_help(void *optctx, const char *opt, const char *arg)
Generic -h handler common to all avtools.
int show_sample_fmts(void *optctx, const char *opt, const char *arg)
Print a listing containing all the sample formats supported by the program.
AVDictionary * codec_opts
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
Trivial log callback.
struct Option Option
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...
int show_filters(void *optctx, const char *opt, const char *arg)
Print a listing containing all the filters supported by the program.
struct SwsContext * sws_opts
AVPixelFormat
Pixel format.
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0...
const char program_name[]
program name, defined by the program for show_version().