00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FFMPEG_CMDUTILS_H
00023 #define FFMPEG_CMDUTILS_H
00024
00025 #include <inttypes.h>
00026 #include "libavcodec/avcodec.h"
00027 #include "libavformat/avformat.h"
00028 #include "libswscale/swscale.h"
00029
00033 extern const char program_name[];
00034
00038 extern const int program_birth_year;
00039
00040 extern const int this_year;
00041
00042 extern const char **opt_names;
00043 extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
00044 extern AVFormatContext *avformat_opts;
00045 extern struct SwsContext *sws_opts;
00046
00051 void init_opts(void);
00056 void uninit_opts(void);
00057
00062 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
00063
00068 int opt_default(const char *opt, const char *arg);
00069
00073 int opt_loglevel(const char *opt, const char *arg);
00074
00078 int opt_timelimit(const char *opt, const char *arg);
00079
00093 double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max);
00094
00109 int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration);
00110
00111 typedef struct {
00112 const char *name;
00113 int flags;
00114 #define HAS_ARG 0x0001
00115 #define OPT_BOOL 0x0002
00116 #define OPT_EXPERT 0x0004
00117 #define OPT_STRING 0x0008
00118 #define OPT_VIDEO 0x0010
00119 #define OPT_AUDIO 0x0020
00120 #define OPT_GRAB 0x0040
00121 #define OPT_INT 0x0080
00122 #define OPT_FLOAT 0x0100
00123 #define OPT_SUBTITLE 0x0200
00124 #define OPT_FUNC2 0x0400
00125 #define OPT_INT64 0x0800
00126 #define OPT_EXIT 0x1000
00127 union {
00128 void (*func_arg)(const char *);
00129 int *int_arg;
00130 char **str_arg;
00131 float *float_arg;
00132 int (*func2_arg)(const char *, const char *);
00133 int64_t *int64_arg;
00134 } u;
00135 const char *help;
00136 const char *argname;
00137 } OptionDef;
00138
00139 void show_help_options(const OptionDef *options, const char *msg, int mask, int value);
00140
00149 void parse_options(int argc, char **argv, const OptionDef *options,
00150 void (* parse_arg_function)(const char*));
00151
00152 void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec);
00153
00163 void print_error(const char *filename, int err);
00164
00165 void list_fmts(void (*get_fmt_string)(char *buf, int buf_size, int fmt), int nb_fmts);
00166
00172 void show_banner(void);
00173
00179 void show_version(void);
00180
00185 void show_license(void);
00186
00191 void show_formats(void);
00192
00197 void show_codecs(void);
00198
00203 void show_filters(void);
00204
00209 void show_bsfs(void);
00210
00215 void show_protocols(void);
00216
00221 void show_pix_fmts(void);
00222
00227 int read_yesno(void);
00228
00238 int read_file(const char *filename, char **bufptr, size_t *size);
00239
00240 typedef struct {
00241 int64_t num_faulty_pts;
00242 int64_t num_faulty_dts;
00243 int64_t last_pts;
00244 int64_t last_dts;
00245 } PtsCorrectionContext;
00246
00250 void init_pts_correction(PtsCorrectionContext *ctx);
00251
00262 int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t pts, int64_t dts);
00263
00281 FILE *get_preset_file(char *filename, size_t filename_size,
00282 const char *preset_name, int is_path, const char *codec_name);
00283
00284 #if CONFIG_AVFILTER
00285 #include "libavfilter/avfilter.h"
00286
00287 typedef struct {
00288 enum PixelFormat pix_fmt;
00289 } FFSinkContext;
00290
00291 extern AVFilter ffsink;
00292
00299 int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
00300 AVFilterBufferRef **picref, AVRational *pts_tb);
00301
00302 #endif
00303
00304 #endif