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
468 #define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
469 #define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
519 #if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
741 unsigned sched_idx_enc,
755 const char *
command,
const char *
arg,
int all_filters);
849 #define SPECIFIER_OPT_FMT_str "%s"
850 #define SPECIFIER_OPT_FMT_i "%i"
851 #define SPECIFIER_OPT_FMT_i64 "%"PRId64
852 #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64
853 #define SPECIFIER_OPT_FMT_f "%f"
854 #define SPECIFIER_OPT_FMT_dbl "%lf"
856 #define WARN_MULTIPLE_OPT_USAGE(optname, type, idx, st)\
858 char namestr[128] = "";\
859 const SpecifierOpt *so = &o->optname.opt[idx];\
860 const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
861 snprintf(namestr, sizeof(namestr), "-%s", o->optname.opt_canon->name);\
862 if (o->optname.opt_canon->flags & OPT_HAS_ALT) {\
863 const char * const *names_alt = o->optname.opt_canon->u1.names_alt;\
864 for (int _i = 0; names_alt[_i]; _i++)\
865 av_strlcatf(namestr, sizeof(namestr), "/-%s", names_alt[_i]);\
867 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",\
868 namestr, st->index, o->optname.opt_canon->name, spec[0] ? ":" : "", spec, so->u.type);\
871 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
873 int _ret, _matches = 0, _match_idx;\
874 for (int _i = 0; _i < o->name.nb_opt; _i++) {\
875 char *spec = o->name.opt[_i].specifier;\
876 if ((_ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
877 outvar = o->name.opt[_i].u.type;\
880 } else if (_ret < 0)\
883 if (_matches > 1 && o->name.opt_canon)\
884 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
AVChannelLayout ch_layout
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
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
float dts_delta_threshold
@ FRAME_OPAQUE_SUB_HEARTBEAT
SpecifierOptList enc_stats_pre_fmt
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
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, Scheduler *sch, unsigned sch_idx_enc, const OutputFilterOptions *opts)
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
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).
@ OFILTER_FLAG_AUDIO_24BIT
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
enum VideoSyncMethod vsync_method
int find_codec(void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **codec)
enum AVPixelFormat * pix_fmts
const OptionDef options[]
SpecifierOptList enc_stats_post_fmt
@ FRAME_OPAQUE_SEND_COMMAND
An AVChannelLayout holds information about the channel layout of audio data.
SpecifierOptList enc_stats_pre
int filtergraph_is_simple(const FilterGraph *fg)
HWDevice * hw_device_get_by_type(enum AVHWDeviceType type)
SpecifierOptList disposition
int fg_finalise_bindings(void)
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
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, unsigned sched_idx_enc, const OutputFilterOptions *opts)
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)
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
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.
@ OFILTER_FLAG_DISABLE_CONVERT
int muxer_thread(void *arg)
int enc_alloc(Encoder **penc, const AVCodec *codec, Scheduler *sch, unsigned sch_idx)
float dts_error_threshold
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