Go to the documentation of this file.
19 #ifndef FFTOOLS_FFMPEG_H
20 #define FFTOOLS_FFMPEG_H
24 #include <stdatomic.h>
54 #define FFMPEG_OPT_QPHIST 1
55 #define FFMPEG_OPT_ADRIFT_THRESHOLD 1
56 #define FFMPEG_OPT_ENC_TIME_BASE_NUM 1
57 #define FFMPEG_OPT_TOP 1
58 #define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1
59 #define FFMPEG_OPT_VSYNC_DROP 1
60 #define FFMPEG_OPT_VSYNC 1
61 #define FFMPEG_OPT_FILTER_SCRIPT 1
63 #define FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D')
71 #if FFMPEG_OPT_VSYNC_DROP
209 #if FFMPEG_OPT_FILTER_SCRIPT
421 #define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
422 #define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
472 #if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
702 unsigned sched_idx_enc);
715 const char *
command,
const char *
arg,
int all_filters);
809 #define SPECIFIER_OPT_FMT_str "%s"
810 #define SPECIFIER_OPT_FMT_i "%i"
811 #define SPECIFIER_OPT_FMT_i64 "%"PRId64
812 #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64
813 #define SPECIFIER_OPT_FMT_f "%f"
814 #define SPECIFIER_OPT_FMT_dbl "%lf"
816 #define WARN_MULTIPLE_OPT_USAGE(optname, type, idx, st)\
818 char namestr[128] = "";\
819 const SpecifierOpt *so = &o->optname.opt[idx];\
820 const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
821 snprintf(namestr, sizeof(namestr), "-%s", o->optname.opt_canon->name);\
822 if (o->optname.opt_canon->flags & OPT_HAS_ALT) {\
823 const char * const *names_alt = o->optname.opt_canon->u1.names_alt;\
824 for (int _i = 0; names_alt[_i]; _i++)\
825 av_strlcatf(namestr, sizeof(namestr), "/-%s", names_alt[_i]);\
827 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",\
828 namestr, st->index, o->optname.opt_canon->name, spec[0] ? ":" : "", spec, so->u.type);\
831 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
833 int _ret, _matches = 0, _match_idx;\
834 for (int _i = 0; _i < o->name.nb_opt; _i++) {\
835 char *spec = o->name.opt[_i].specifier;\
836 if ((_ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
837 outvar = o->name.opt[_i].u.type;\
840 } else if (_ret < 0)\
843 if (_matches > 1 && o->name.opt_canon)\
844 WARN_MULTIPLE_OPT_USAGE(name, type, _match_idx, st);\
const uint8_t * subtitle_header
AVCodecParameters * par_enc
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
SpecifierOptList force_fps
SpecifierOptList forced_key_frames
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, unsigned sched_idx_enc)
This struct describes the properties of an encoded stream.
@ DECODER_FLAG_SEND_END_TS
int enc_open(void *opaque, const AVFrame *frame)
void fg_free(FilterGraph **pfg)
AVCodecParameters * par_in
Codec parameters for packets submitted to the muxer (i.e.
float frame_drop_threshold
atomic_uint_least64_t packets_written
SpecifierOptList bits_per_raw_sample
SpecifierOptList audio_ch_layouts
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
AVIOContext * progress_avio
This structure describes decoded (raw) audio or video data.
@ DECODER_FLAG_FRAMERATE_FORCED
int64_t of_filesize(OutputFile *of)
SpecifierOptList display_hflips
const AVCodecParameters * par
SpecifierOptList passlogfiles
enum HWAccelID hwaccel_id
const AVIOInterruptCB int_cb
int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
Create a new filtergraph in the global filtergraph list.
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)
@ IFILTER_FLAG_AUTOROTATE
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, Scheduler *sch, unsigned sch_idx_enc)
unsigned int fix_sub_duration_heartbeat
int enc_loopback(Encoder *enc)
SpecifierOptList frame_pix_fmts
SpecifierOptList canvas_sizes
Callback for checking whether to abort blocking functions.
enum AVPixelFormat hwaccel_output_format
SpecifierOptList max_frame_rates
enum VideoSyncMethod vsync_method
float dts_delta_threshold
@ FRAME_OPAQUE_SUB_HEARTBEAT
SpecifierOptList enc_stats_pre_fmt
int fg_finalise_bindings(FilterGraph *fg)
SpecifierOptList mux_stats_fmt
int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
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
void fg_send_command(FilterGraph *fg, double time, const char *target, const char *command, const char *arg, int all_filters)
@ LATENCY_PROBE_FILTER_PRE
AVRational frame_rate_filter
SpecifierOptList hwaccel_output_formats
SpecifierOptList metadata
atomic_uint nb_output_dumped
void of_free(OutputFile **pof)
EncStatsComponent * components
int assert_file_overwrite(const char *filename)
SpecifierOptList intra_matrices
SpecifierOptList stream_groups
AVRational frame_aspect_ratio
@ KF_FORCE_SOURCE_NO_DROP
int dec_init(Decoder **pdec, Scheduler *sch, AVDictionary **dec_opts, const DecoderOpts *o, AVFrame *param_out)
SpecifierOptList hwaccel_devices
SpecifierOptList autoscale
struct OutputStream * ost
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, InputFilterOptions *opts)
SpecifierOptList sample_fmts
int ignore_unknown_streams
int encoder_thread(void *arg)
SpecifierOptList fix_sub_duration
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
double expr_const_values[FKF_NB]
void of_enc_stats_close(void)
AVDictionary * encoder_opts
Describe the class of an AVClass context structure.
int dec_create(const OptionsContext *o, const char *arg, Scheduler *sch)
Create a standalone decoder.
int dec_filter_add(Decoder *dec, InputFilter *ifilter, InputFilterOptions *opts)
const char *const forced_keyframes_const_names[]
SpecifierOptList audio_channels
SpecifierOptList fix_sub_duration_heartbeat
int hw_device_init_from_type(enum AVHWDeviceType type, const char *device, HWDevice **dev_out)
Rational number (pair of numerator and denominator).
SpecifierOptList copy_prior_start
SpecifierOptList frame_aspect_ratios
SpecifierOptList reinit_filters
SpecifierOptList dump_attachment
int64_t wallclock[LATENCY_PROBE_NB]
const FrameData * packet_data_c(AVPacket *pkt)
void update_benchmark(const char *fmt,...)
SpecifierOptList display_vflips
SpecifierOptList max_frames
FilterGraph ** filtergraphs
@ DECODER_FLAG_FIX_SUB_DURATION
int find_codec(void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **codec)
const OptionDef options[]
SpecifierOptList enc_stats_post_fmt
@ FRAME_OPAQUE_SEND_COMMAND
SpecifierOptList enc_stats_pre
int filtergraph_is_simple(const FilterGraph *fg)
HWDevice * hw_device_get_by_type(enum AVHWDeviceType type)
SpecifierOptList disposition
double readrate_initial_burst
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
SpecifierOptList display_rotations
AVDictionary * strip_specifiers(const AVDictionary *dict)
SpecifierOptList ts_scale
SpecifierOptList chroma_intra_matrices
AVRational max_frame_rate
SpecifierOptList frame_rates
SpecifierOptList codec_names
SpecifierOptList autorotate
SpecifierOptList fps_mode
float shortest_buf_duration
SpecifierOptList mux_stats
OutputFile ** output_files
SpecifierOptList muxing_queue_data_threshold
SpecifierOptList hwaccels
OutputStream * ost_iter(OutputStream *prev)
SpecifierOptList enc_stats_post
char * attachment_filename
SpecifierOptList metadata_map
void dec_free(Decoder **pdec)
void enc_free(Encoder **penc)
FrameData * packet_data(AVPacket *pkt)
@ DECODER_FLAG_TOP_FIELD_FIRST
void hw_device_free_all(void)
void ifile_close(InputFile **f)
SpecifierOptList max_muxing_queue_size
HWDevice * filter_hw_device
main external API structure.
SpecifierOptList inter_matrices
SpecifierOptList audio_sample_rate
@ PKT_OPAQUE_SUB_HEARTBEAT
int ist_output_add(InputStream *ist, OutputStream *ost)
const FrameData * frame_data_c(AVFrame *frame)
int check_avoptions(AVDictionary *m)
SpecifierOptList frame_sizes
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
enum VideoSyncMethod video_sync_method
void remove_avoptions(AVDictionary **a, AVDictionary *b)
SpecifierOptList codec_tags
SpecifierOptList filter_scripts
SpecifierOptList time_bases
A reference to a data buffer.
InputStream * ist_iter(InputStream *prev)
@ DECODER_FLAG_TS_UNRELIABLE
atomic_uint_least64_t nb_frames_drop
int auto_conversion_filters
SpecifierOptList rc_overrides
int of_open(const OptionsContext *o, const char *filename, Scheduler *sch)
SpecifierOptList copy_initial_nonkeyframes
const char ** attachments
This structure stores compressed data.
int muxer_thread(void *arg)
int enc_alloc(Encoder **penc, const AVCodec *codec, Scheduler *sch, unsigned sch_idx)
float dts_error_threshold
const AVOutputFormat * format
AVBufferRef * hw_device_for_filter(void)
Get a hardware device to be used with this filtergraph.
const char * opt_match_per_type_str(const SpecifierOptList *sol, char mediatype)
SpecifierOptList guess_layout_max
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)
@ PKT_OPAQUE_FIX_SUB_DURATION
enum AVHWDeviceType hwaccel_device_type
int of_write_trailer(OutputFile *of)
InputStream * ist_find_unused(enum AVMediaType type)
Find an unused input stream of given type.
SpecifierOptList bitstream_filters
intptr_t atomic_uint_least64_t
SpecifierOptList enc_time_bases
SpecifierOptList top_field_first
atomic_uint_least64_t nb_frames_dup
int filter_complex_nbthreads
@ LATENCY_PROBE_FILTER_POST