Go to the documentation of this file.
19 #ifndef FFTOOLS_FFMPEG_H
20 #define FFTOOLS_FFMPEG_H
24 #include <stdatomic.h>
53 #define FFMPEG_OPT_PSNR 1
54 #define FFMPEG_OPT_MAP_CHANNEL 1
55 #define FFMPEG_OPT_MAP_SYNC 1
56 #define FFMPEG_ROTATION_METADATA 1
67 #define MAX_STREAMS 1024
89 #if FFMPEG_OPT_MAP_CHANNEL
148 #if FFMPEG_OPT_MAP_CHANNEL
341 #define DECODING_FOR_OST 1
342 #define DECODING_FOR_FILTER 2
496 #define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
497 #define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
608 #if FFMPEG_ROTATION_METADATA
614 #if FFMPEG_ROTATION_METADATA
623 #if FFMPEG_OPT_MAP_CHANNEL
856 #define SPECIFIER_OPT_FMT_str "%s"
857 #define SPECIFIER_OPT_FMT_i "%i"
858 #define SPECIFIER_OPT_FMT_i64 "%"PRId64
859 #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64
860 #define SPECIFIER_OPT_FMT_f "%f"
861 #define SPECIFIER_OPT_FMT_dbl "%lf"
863 #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
865 char namestr[128] = "";\
866 const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
867 for (int _i = 0; opt_name_##name[_i]; _i++)\
868 av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[_i], opt_name_##name[_i+1] ? (opt_name_##name[_i+2] ? ", " : " or ") : "");\
869 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",\
870 namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
873 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
875 int _ret, _matches = 0;\
877 for (int _i = 0; _i < o->nb_ ## name; _i++) {\
878 char *spec = o->name[_i].specifier;\
879 if ((_ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
880 outvar = o->name[_i].u.type;\
883 } else if (_ret < 0)\
887 WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
890 #define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
893 for (i = 0; i < o->nb_ ## name; i++) {\
894 char *spec = o->name[i].specifier;\
895 if (!strcmp(spec, mediatype))\
896 outvar = o->name[i].u.type;\
int of_open(const OptionsContext *o, const char *filename)
SpecifierOpt * enc_stats_post_fmt
AVPixelFormat
Pixel format.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
struct FilterGraph * graph
SpecifierOpt * canvas_sizes
SpecifierOpt * dump_attachment
const char * attachment_filename
const AVChannelLayout * ch_layouts
int configure_filtergraph(FilterGraph *fg)
SpecifierOpt * intra_matrices
@ KF_FORCE_SOURCE_NO_DROP
This struct describes the properties of an encoded stream.
static float sub(float src0, float src1)
float frame_drop_threshold
SpecifierOpt * rc_overrides
atomic_uint_least64_t packets_written
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
int64_t start_time
start time in microseconds == AV_TIME_BASE units
SpecifierOpt * frame_aspect_ratios
AVIOContext * progress_avio
int ffmpeg_parse_options(int argc, char **argv)
This structure describes decoded (raw) audio or video data.
int64_t of_filesize(OutputFile *of)
int nb_chroma_intra_matrices
SpecifierOpt * inter_matrices
const AVIOInterruptCB int_cb
SpecifierOpt * audio_channels
int hw_device_init_from_string(const char *arg, HWDevice **dev)
void enc_stats_write(OutputStream *ost, EncStats *es, const AVFrame *frame, const AVPacket *pkt, uint64_t frame_num)
double rotate_override_value
unsigned int fix_sub_duration_heartbeat
Callback for checking whether to abort blocking functions.
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
SpecifierOpt * display_rotations
enum VideoSyncMethod vsync_method
float dts_delta_threshold
char * filters
filtergraph associated to the -filter option
void assert_file_overwrite(const char *filename)
const char *const opt_name_codec_names[]
int64_t vsync_frame_number
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
int hw_device_setup_for_decode(InputStream *ist)
void assert_avoptions(AVDictionary *m)
SpecifierOpt * time_bases
int nb_audio_channel_maps
int copy_initial_nonkeyframes
SpecifierOpt * enc_stats_post
SpecifierOpt * copy_initial_nonkeyframes
SpecifierOpt * codec_names
EncStatsComponent * components
AVRational frame_aspect_ratio
int nb_bits_per_raw_sample
int audio_channels_mapped
SpecifierOpt * audio_ch_layouts
struct OutputStream * ost
int ignore_unknown_streams
float audio_drift_threshold
int nb_copy_initial_nonkeyframes
SpecifierOpt * sample_fmts
int nb_max_muxing_queue_size
double expr_const_values[FKF_NB]
void of_enc_stats_close(void)
AVDictionary * encoder_opts
SpecifierOpt * reinit_filters
Describe the class of an AVClass context structure.
int nb_fix_sub_duration_heartbeat
const char *const forced_keyframes_const_names[]
SpecifierOpt * frame_sizes
void of_close(OutputFile **pof)
Rational number (pair of numerator and denominator).
SpecifierOpt * fix_sub_duration
SpecifierOpt * codec_tags
int ifile_get_packet(InputFile *f, AVPacket **pkt)
Get next input packet from the demuxer.
const char *const opt_name_top_field_first[]
SpecifierOpt * max_frames
FilterGraph ** filtergraphs
SpecifierOpt * display_hflips
unsigned nb_output_dumped
const OptionDef options[]
int nb_frame_aspect_ratios
void sub2video_update(InputStream *ist, int64_t heartbeat_pts, AVSubtitle *sub)
An AVChannelLayout holds information about the channel layout of audio data.
SpecifierOpt * filter_scripts
int hwaccel_decode_init(AVCodecContext *avctx)
SpecifierOpt * top_field_first
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
AVDictionary * strip_specifiers(const AVDictionary *dict)
void check_filter_outputs(void)
SpecifierOpt * frame_rates
SpecifierOpt * autorotate
AVRational max_frame_rate
char * filters_script
filtergraph script associated to the -filter_script option
int nb_hwaccel_output_formats
int init_complex_filtergraph(FilterGraph *fg)
SpecifierOpt * forced_key_frames
void of_output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof)
SpecifierOpt * mux_stats_fmt
SpecifierOpt * metadata_map
SpecifierOpt * enc_stats_pre
const AVCodec * find_codec_or_die(void *logctx, const char *name, enum AVMediaType type, int encoder)
SpecifierOpt * audio_sample_rate
float shortest_buf_duration
OutputFile ** output_files
int64_t last_nb0_frames[3]
int hw_device_setup_for_filter(FilterGraph *fg)
SpecifierOpt * bits_per_raw_sample
SpecifierOpt * bitstream_filters
SpecifierOpt * passlogfiles
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
AVChannelLayout ch_layout
AudioChannelMap * audio_channel_maps
void hw_device_free_all(void)
void ifile_close(InputFile **f)
SpecifierOpt * disposition
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
int ifile_open(const OptionsContext *o, const char *filename)
HWDevice * filter_hw_device
main external API structure.
int hw_device_setup_for_encode(OutputStream *ost)
SpecifierOpt * fix_sub_duration_heartbeat
SpecifierOpt * guess_layout_max
SpecifierOpt * enc_time_bases
SpecifierOpt * max_frame_rates
SpecifierOpt * frame_pix_fmts
enum VideoSyncMethod video_sync_method
SpecifierOpt * hwaccel_devices
SpecifierOpt * max_muxing_queue_size
void remove_avoptions(AVDictionary **a, AVDictionary *b)
int nb_muxing_queue_data_threshold
SpecifierOpt * enc_stats_pre_fmt
SpecifierOpt * muxing_queue_data_threshold
A reference to a data buffer.
SpecifierOpt * copy_prior_start
InputStream * ist_iter(InputStream *prev)
int auto_conversion_filters
const char *const opt_name_frame_rates[]
const char ** attachments
int nb_enc_stats_post_fmt
This structure stores compressed data.
SpecifierOpt * chroma_intra_matrices
char * file_read(const char *filename)
float dts_error_threshold
SpecifierOpt * hwaccel_output_formats
const AVOutputFormat * format
const char *const opt_name_codec_tags[]
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
int of_stream_init(OutputFile *of, OutputStream *ost)
HWDevice * hw_device_get_by_name(const char *name)
A linked-list of the inputs/outputs of the filter chain.
int of_write_trailer(OutputFile *of)
int filtergraph_is_simple(FilterGraph *fg)
SpecifierOpt * display_vflips
intptr_t atomic_uint_least64_t
int filter_complex_nbthreads