mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-24 00:02:52 +00:00
fftools/ffmpeg_opt: move opening output files into a new file
ffmpeg_opt.c currently contains code for - parsing the options provided on the command line - opening and initializing input files based on these options - opening and initializing output files based on these options The code dealing with each of these is for the most part disjoint, so it makes sense to move them to separate files. Beyond reducing the quite considerable size of ffmpeg_opt.c, this will also allow exposing muxer internals (currently private to ffmpeg_mux.c) to the initialization code, thus removing the awkward separation currently in place.
This commit is contained in:
parent
965bff37b6
commit
18d6c07267
@ -14,6 +14,7 @@ OBJS-ffmpeg += \
|
||||
fftools/ffmpeg_filter.o \
|
||||
fftools/ffmpeg_hw.o \
|
||||
fftools/ffmpeg_mux.o \
|
||||
fftools/ffmpeg_mux_init.o \
|
||||
fftools/ffmpeg_opt.o \
|
||||
fftools/objpool.o \
|
||||
fftools/sync_queue.o \
|
||||
|
@ -686,6 +686,13 @@ extern HWDevice *filter_hw_device;
|
||||
extern unsigned nb_output_dumped;
|
||||
extern int main_return_code;
|
||||
|
||||
extern int input_stream_potentially_available;
|
||||
extern int ignore_unknown_streams;
|
||||
extern int copy_unknown_streams;
|
||||
|
||||
#if FFMPEG_OPT_PSNR
|
||||
extern int do_psnr;
|
||||
#endif
|
||||
|
||||
void term_init(void);
|
||||
void term_exit(void);
|
||||
@ -695,6 +702,12 @@ void show_usage(void);
|
||||
void remove_avoptions(AVDictionary **a, AVDictionary *b);
|
||||
void assert_avoptions(AVDictionary *m);
|
||||
|
||||
void assert_file_overwrite(const char *filename);
|
||||
char *read_file(const char *filename);
|
||||
AVDictionary *strip_specifiers(AVDictionary *dict);
|
||||
const AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder);
|
||||
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg);
|
||||
void check_filter_outputs(void);
|
||||
int filtergraph_is_simple(FilterGraph *fg);
|
||||
@ -729,6 +742,7 @@ int of_muxer_init(OutputFile *of, AVFormatContext *fc,
|
||||
*/
|
||||
int of_stream_init(OutputFile *of, OutputStream *ost);
|
||||
int of_write_trailer(OutputFile *of);
|
||||
int of_open(OptionsContext *o, const char *filename);
|
||||
void of_close(OutputFile **pof);
|
||||
|
||||
/*
|
||||
@ -761,4 +775,59 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt);
|
||||
int init_input_threads(void);
|
||||
void free_input_threads(void);
|
||||
|
||||
#define SPECIFIER_OPT_FMT_str "%s"
|
||||
#define SPECIFIER_OPT_FMT_i "%i"
|
||||
#define SPECIFIER_OPT_FMT_i64 "%"PRId64
|
||||
#define SPECIFIER_OPT_FMT_ui64 "%"PRIu64
|
||||
#define SPECIFIER_OPT_FMT_f "%f"
|
||||
#define SPECIFIER_OPT_FMT_dbl "%lf"
|
||||
|
||||
#define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
|
||||
{\
|
||||
char namestr[128] = "";\
|
||||
const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
|
||||
for (i = 0; opt_name_##name[i]; i++)\
|
||||
av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? (opt_name_##name[i+2] ? ", " : " or ") : "");\
|
||||
av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\
|
||||
namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
|
||||
}
|
||||
|
||||
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
|
||||
{\
|
||||
int i, ret, matches = 0;\
|
||||
SpecifierOpt *so;\
|
||||
for (i = 0; i < o->nb_ ## name; i++) {\
|
||||
char *spec = o->name[i].specifier;\
|
||||
if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
|
||||
outvar = o->name[i].u.type;\
|
||||
so = &o->name[i];\
|
||||
matches++;\
|
||||
} else if (ret < 0)\
|
||||
exit_program(1);\
|
||||
}\
|
||||
if (matches > 1)\
|
||||
WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
|
||||
}
|
||||
|
||||
#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
|
||||
{\
|
||||
int i;\
|
||||
for (i = 0; i < o->nb_ ## name; i++) {\
|
||||
char *spec = o->name[i].specifier;\
|
||||
if (!strcmp(spec, mediatype))\
|
||||
outvar = o->name[i].u.type;\
|
||||
}\
|
||||
}
|
||||
|
||||
extern const char * const opt_name_audio_channels[];
|
||||
extern const char * const opt_name_audio_ch_layouts[];
|
||||
extern const char * const opt_name_audio_sample_rate[];
|
||||
extern const char * const opt_name_codec_names[];
|
||||
extern const char * const opt_name_codec_tags[];
|
||||
extern const char * const opt_name_frame_rates[];
|
||||
extern const char * const opt_name_frame_sizes[];
|
||||
extern const char * const opt_name_frame_pix_fmts[];
|
||||
extern const char * const opt_name_sample_fmts[];
|
||||
extern const char * const opt_name_top_field_first[];
|
||||
|
||||
#endif /* FFTOOLS_FFMPEG_H */
|
||||
|
1887
fftools/ffmpeg_mux_init.c
Normal file
1887
fftools/ffmpeg_mux_init.c
Normal file
File diff suppressed because it is too large
Load Diff
1926
fftools/ffmpeg_opt.c
1926
fftools/ffmpeg_opt.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user