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
57 #define FFMPEG_OPT_QPHIST 1
58 #define FFMPEG_OPT_ADRIFT_THRESHOLD 1
59 #define FFMPEG_OPT_ENC_TIME_BASE_NUM 1
60 #define FFMPEG_OPT_TOP 1
61 #define FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1
97 #if FFMPEG_OPT_MAP_CHANNEL
163 #if FFMPEG_OPT_MAP_CHANNEL
334 #define DECODING_FOR_OST 1
335 #define DECODING_FOR_FILTER 2
444 #define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
445 #define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
491 #if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
551 #if FFMPEG_ROTATION_METADATA
557 #if FFMPEG_ROTATION_METADATA
566 #if FFMPEG_OPT_MAP_CHANNEL
770 const char *command,
const char *
arg,
int all_filters);
891 return (err0 < 0) ? err0 :
FFMIN(err1, 0);
894 #define SPECIFIER_OPT_FMT_str "%s"
895 #define SPECIFIER_OPT_FMT_i "%i"
896 #define SPECIFIER_OPT_FMT_i64 "%"PRId64
897 #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64
898 #define SPECIFIER_OPT_FMT_f "%f"
899 #define SPECIFIER_OPT_FMT_dbl "%lf"
901 #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
903 char namestr[128] = "";\
904 const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
905 for (int _i = 0; opt_name_##name[_i]; _i++)\
906 av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[_i], opt_name_##name[_i+1] ? (opt_name_##name[_i+2] ? ", " : " or ") : "");\
907 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",\
908 namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
911 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
913 int _ret, _matches = 0;\
915 for (int _i = 0; _i < o->nb_ ## name; _i++) {\
916 char *spec = o->name[_i].specifier;\
917 if ((_ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
918 outvar = o->name[_i].u.type;\
921 } else if (_ret < 0)\
925 WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
928 #define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
931 for (i = 0; i < o->nb_ ## name; i++) {\
932 char *spec = o->name[i].specifier;\
933 if (!strcmp(spec, mediatype))\
934 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
int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts)
SpecifierOpt * canvas_sizes
SpecifierOpt * dump_attachment
const char * attachment_filename
SpecifierOpt * intra_matrices
@ KF_FORCE_SOURCE_NO_DROP
This struct describes the properties of an encoded stream.
int reap_filters(FilterGraph *fg, int flush)
Get and encode new output from specified filtergraph, without causing activity.
void fg_free(FilterGraph **pfg)
AVCodecParameters * par_in
Codec parameters for packets submitted to the muxer (i.e.
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
int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec)
Set up fallback filtering parameters from a decoder context.
SpecifierOpt * inter_matrices
const AVIOInterruptCB int_cb
int fg_create(FilterGraph **pfg, char *graph_desc)
Create a new filtergraph in the global filtergraph list.
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
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
Callback for checking whether to abort blocking functions.
SpecifierOpt * display_rotations
enum VideoSyncMethod vsync_method
float dts_delta_threshold
int enc_open(OutputStream *ost, const AVFrame *frame)
int trigger_fix_sub_duration_heartbeat(OutputStream *ost, const AVPacket *pkt)
const char *const opt_name_codec_names[]
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
SpecifierOpt * time_bases
void fg_send_command(FilterGraph *fg, double time, const char *target, const char *command, const char *arg, int all_filters)
int nb_audio_channel_maps
int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub)
AVRational frame_rate_filter
SpecifierOpt * enc_stats_post
SpecifierOpt * copy_initial_nonkeyframes
SpecifierOpt * codec_names
int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy)
int fg_transcode_step(FilterGraph *graph, InputStream **best_ist)
Perform a step of transcoding for the specified filter graph.
void of_free(OutputFile **pof)
EncStatsComponent * components
int assert_file_overwrite(const char *filename)
This struct describes the properties of a single codec described by an AVCodecID.
AVRational frame_aspect_ratio
void ifilter_sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational tb)
int nb_bits_per_raw_sample
int audio_channels_mapped
int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
SpecifierOpt * audio_ch_layouts
struct OutputStream * ost
int ignore_unknown_streams
int nb_copy_initial_nonkeyframes
SpecifierOpt * sample_fmts
int nb_max_muxing_queue_size
int dec_open(InputStream *ist)
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
int hw_device_init_from_type(enum AVHWDeviceType type, const char *device, HWDevice **dev_out)
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[]
void update_benchmark(const char *fmt,...)
SpecifierOpt * max_frames
FilterGraph ** filtergraphs
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
int find_codec(void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **codec)
static void frame_move(void *dst, void *src)
SpecifierOpt * display_hflips
unsigned nb_output_dumped
const OptionDef options[]
int nb_frame_aspect_ratios
static void copy(const float *p1, float *p2, const int length)
int filtergraph_is_simple(const FilterGraph *fg)
int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference)
int check_filter_outputs(void)
SpecifierOpt * filter_scripts
SpecifierOpt * top_field_first
HWDevice * hw_device_get_by_type(enum AVHWDeviceType type)
double readrate_initial_burst
int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts)
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
int enc_alloc(Encoder **penc, const AVCodec *codec)
int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src)
static void pkt_move(void *dst, void *src)
AVDictionary * strip_specifiers(const AVDictionary *dict)
void close_output_stream(OutputStream *ost)
SpecifierOpt * frame_rates
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
SpecifierOpt * autorotate
AVRational max_frame_rate
int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
int nb_hwaccel_output_formats
int init_complex_filtergraph(FilterGraph *fg)
SpecifierOpt * forced_key_frames
SpecifierOpt * mux_stats_fmt
SpecifierOpt * metadata_map
SpecifierOpt * enc_stats_pre
SpecifierOpt * audio_sample_rate
float shortest_buf_duration
OutputFile ** output_files
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
OutputStream * ost_iter(OutputStream *prev)
SpecifierOpt * bits_per_raw_sample
SpecifierOpt * bitstream_filters
SpecifierOpt * passlogfiles
void dec_free(Decoder **pdec)
void enc_free(Encoder **penc)
int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
Submit a packet for decoding.
AudioChannelMap * audio_channel_maps
void hw_device_free_all(void)
A sync queue provides timestamp synchronization between multiple streams.
void ifile_close(InputFile **f)
SpecifierOpt * disposition
int ifile_open(const OptionsContext *o, const char *filename)
HWDevice * filter_hw_device
main external API structure.
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc)
SpecifierOpt * fix_sub_duration_heartbeat
int ist_output_add(InputStream *ist, OutputStream *ost)
SpecifierOpt * guess_layout_max
int check_avoptions(AVDictionary *m)
SpecifierOpt * enc_time_bases
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
SpecifierOpt * max_frame_rates
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
SpecifierOpt * frame_pix_fmts
enum VideoSyncMethod video_sync_method
int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb)
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
void(* flush)(AVBSFContext *ctx)
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.
int ifilter_sub2video(InputFilter *ifilter, const AVFrame *frame)
SpecifierOpt * chroma_intra_matrices
char * file_read(const char *filename)
float dts_error_threshold
SpecifierOpt * hwaccel_output_formats
static int err_merge(int err0, int err1)
Merge two return codes - return one of the error codes if at least one of them was negative,...
const AVOutputFormat * format
AVBufferRef * hw_device_for_filter(void)
Get a hardware device to be used with this filtergraph.
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)
int enc_frame(OutputStream *ost, AVFrame *frame)
int of_write_trailer(OutputFile *of)
InputStream * ist_find_unused(enum AVMediaType type)
Find an unused input stream of given type.
SpecifierOpt * display_vflips
intptr_t atomic_uint_least64_t
int filter_complex_nbthreads