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 char **opt_names;
00041 extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
00042 extern AVFormatContext *avformat_opts;
00043 extern struct SwsContext *sws_opts;
00044
00049 void init_opts(void);
00054 void uninit_opts(void);
00055
00060 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
00061
00066 int opt_default(const char *opt, const char *arg);
00067
00071 int opt_loglevel(const char *opt, const char *arg);
00072
00076 int opt_timelimit(const char *opt, const char *arg);
00077
00091 double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max);
00092
00107 int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration);
00108
00109 typedef struct {
00110 const char *name;
00111 int flags;
00112 #define HAS_ARG 0x0001
00113 #define OPT_BOOL 0x0002
00114 #define OPT_EXPERT 0x0004
00115 #define OPT_STRING 0x0008
00116 #define OPT_VIDEO 0x0010
00117 #define OPT_AUDIO 0x0020
00118 #define OPT_GRAB 0x0040
00119 #define OPT_INT 0x0080
00120 #define OPT_FLOAT 0x0100
00121 #define OPT_SUBTITLE 0x0200
00122 #define OPT_FUNC2 0x0400
00123 #define OPT_INT64 0x0800
00124 #define OPT_EXIT 0x1000
00125 union {
00126 void (*func_arg)(const char *);
00127 int *int_arg;
00128 char **str_arg;
00129 float *float_arg;
00130 int (*func2_arg)(const char *, const char *);
00131 int64_t *int64_arg;
00132 } u;
00133 const char *help;
00134 const char *argname;
00135 } OptionDef;
00136
00137 void show_help_options(const OptionDef *options, const char *msg, int mask, int value);
00138
00147 void parse_options(int argc, char **argv, const OptionDef *options,
00148 void (* parse_arg_function)(const char*));
00149
00150 void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec);
00151
00161 void print_error(const char *filename, int err);
00162
00163 void list_fmts(void (*get_fmt_string)(char *buf, int buf_size, int fmt), int nb_fmts);
00164
00170 void show_banner(void);
00171
00177 void show_version(void);
00178
00183 void show_license(void);
00184
00189 void show_formats(void);
00190
00195 void show_codecs(void);
00196
00201 void show_filters(void);
00202
00207 void show_bsfs(void);
00208
00213 void show_protocols(void);
00214
00219 void show_pix_fmts(void);
00220
00225 int read_yesno(void);
00226
00236 int read_file(const char *filename, char **bufptr, size_t *size);
00237
00238 typedef struct {
00239 int64_t num_faulty_pts;
00240 int64_t num_faulty_dts;
00241 int64_t last_pts;
00242 int64_t last_dts;
00243 } PtsCorrectionContext;
00244
00248 void init_pts_correction(PtsCorrectionContext *ctx);
00249
00260 int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t pts, int64_t dts);
00261
00279 FILE *get_preset_file(char *filename, size_t filename_size,
00280 const char *preset_name, int is_path, const char *codec_name);
00281
00282 #if CONFIG_AVFILTER
00283 #include "libavfilter/avfilter.h"
00284
00285 typedef struct {
00286 enum PixelFormat pix_fmt;
00287 } FFSinkContext;
00288
00289 extern AVFilter ffsink;
00290
00297 int get_filtered_video_frame(AVFilterContext *sink, AVFrame *frame,
00298 AVFilterBufferRef **picref, AVRational *pts_tb);
00299
00300 #endif
00301
00302 #endif