Go to the documentation of this file.
64 int i, j, *fmts, count = 0;
66 for (
i = 0;
i < n;
i++) {
74 for (j = 0,
i = 0;
i < n;
i++) {
102 int stream_idx, sink_idx;
105 for (stream_idx = 0; stream_idx < lavfi->
nb_sinks; stream_idx++) {
127 const AVFilter *buffersink, *abuffersink;
132 #define FAIL(ERR) { ret = ERR; goto end; }
142 "Only one of the graph or graph_file options must be specified\n");
147 AVBPrint graph_file_pb;
175 &input_links, &output_links, avctx)) < 0)
180 "Open inputs in the filtergraph are not acceptable\n");
185 for (n = 0, inout = output_links; inout; n++, inout = inout->next);
197 for (
i = 0;
i < n;
i++)
202 for (
i = 0, inout = output_links; inout;
i++, inout = inout->next) {
203 int stream_idx = 0,
suffix = 0, use_subcc = 0;
204 sscanf(inout->name,
"out%n%d%n", &
suffix, &stream_idx, &
suffix);
207 "Invalid outpad name '%s'\n", inout->name);
210 if (inout->name[
suffix]) {
211 if (!strcmp(inout->name +
suffix,
"+subcc")) {
215 "Invalid outpad suffix '%s'\n", inout->name);
220 if ((
unsigned)stream_idx >= n) {
222 "Invalid index was specified in output '%s', "
223 "must be a non-negative value < %d\n",
230 "An output with stream index %d was already specified\n",
240 for (
i = 0, inout = output_links; inout;
i++, inout = inout->next) {
252 for (
i = 0, inout = output_links; inout;
i++, inout = inout->next) {
291 "Output '%s' is not a video or audio output, not yet supported\n", inout->name);
342 "Could not find PCM codec for sample format %s.\n",
383 double min_pts = DBL_MAX;
384 int stream_idx, min_pts_sink_idx = 0;
409 ff_dlog(avctx,
"EOF sink_idx:%d\n",
i);
415 ff_dlog(avctx,
"sink_idx:%d time:%f\n",
i,
d);
420 min_pts_sink_idx =
i;
423 if (min_pts == DBL_MAX)
426 ff_dlog(avctx,
"min_pts_sink_idx:%i\n", min_pts_sink_idx);
430 st = avctx->
streams[stream_idx];
447 frame_metadata =
frame->metadata;
448 if (frame_metadata) {
457 metadata,
size)) < 0) {
478 #define OFFSET(x) offsetof(LavfiContext, x)
480 #define DEC AV_OPT_FLAG_DECODING_PARAM
#define AV_BPRINT_SIZE_UNLIMITED
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *ctx)
static av_cold int lavfi_read_header(AVFormatContext *avctx)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
This struct describes the properties of an encoded stream.
static enum AVSampleFormat sample_fmts[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
static int create_subcc_packet(AVFormatContext *avctx, AVFrame *frame, int sink_idx)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define av_opt_set_int_list(obj, name, val, term, flags)
Set a binary option to an integer list.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
AVStream ** streams
A list of all streams in the file.
int64_t probesize
Maximum number of bytes read from input in order to determine stream properties.
const char * name
Filter name.
static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
@ AV_PIX_FMT_NB
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
static av_cold int read_close(AVFormatContext *ctx)
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
@ AV_CLASS_CATEGORY_DEVICE_INPUT
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_BUFFERSINK_FLAG_PEEK
Tell av_buffersink_get_buffer_ref() to read video/samples buffer reference, but not remove it from th...
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
AVRational sample_aspect_ratio
Video only.
static const AVClass lavfi_class
int av_buffersink_get_format(const AVFilterContext *ctx)
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
static enum AVPixelFormat pix_fmts[]
static const AVOption options[]
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int search_flags)
Rational number (pair of numerator and denominator).
char * protocol_whitelist
',' separated list of allowed protocols.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
uint64_t av_buffersink_get_channel_layout(const AVFilterContext *ctx)
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
int sample_rate
Audio only.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
const AVInputFormat ff_lavfi_demuxer
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
char * url
input or output URL.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int * sink_stream_subcc_map
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters.
uint8_t * av_packet_pack_dictionary(AVDictionary *dict, size_t *size)
Pack a dictionary for use in side_data.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
enum AVMediaType av_buffersink_get_type(const AVFilterContext *ctx)
int av_buffersink_get_w(const AVFilterContext *ctx)
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
static int create_subcc_streams(AVFormatContext *avctx)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
Add a graph described by a string to a graph.
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
#define av_malloc_array(a, b)
AVSampleFormat
Audio sample formats.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
@ AV_SAMPLE_FMT_S16
signed 16 bits
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_buffersink_get_h(const AVFilterContext *ctx)
int id
Format-specific stream ID.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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
char * avfilter_graph_dump(AVFilterGraph *graph, const char *options)
Dump a graph into a human-readable string representation.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
static av_cold int lavfi_read_close(AVFormatContext *avctx)
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
int av_buffersink_get_channels(const AVFilterContext *ctx)
static int * create_all_formats(int n)
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
Structure to hold side data for an AVFrame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int av_image_copy_to_buffer(uint8_t *dst, int dst_size, const uint8_t *const src_data[4], const int src_linesize[4], enum AVPixelFormat pix_fmt, int width, int height, int align)
Copy image data from an image into a buffer.
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int64_t pos
byte position in stream, -1 if unknown
uint64_t channel_layout
Audio only.
#define flags(name, subs,...)
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S32
signed 32 bits
A linked-list of the inputs/outputs of the filter chain.
void * priv_data
Format private data.
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.