79 int stream_idx, sink_idx;
82 for (stream_idx = 0; stream_idx < lavfi->
nb_sinks; stream_idx++) {
104 const AVFilter *buffersink, *abuffersink;
108#define FAIL(ERR) { ret = ERR; goto end; }
115 "Only one of the graph or graph_file options must be specified\n");
120 AVBPrint graph_file_pb;
148 &input_links, &output_links, avctx)) < 0)
153 "Open inputs in the filtergraph are not acceptable\n");
158 for (n = 0, inout = output_links; inout; n++, inout = inout->next);
170 for (
i = 0;
i < n;
i++)
175 for (
i = 0, inout = output_links; inout;
i++, inout = inout->next) {
176 int stream_idx = 0, suffix = 0, use_subcc = 0;
181 sscanf(inout->name,
"out%n%d%n", &suffix, &stream_idx, &suffix);
184 "Invalid outpad name '%s'\n", inout->name);
187 if (inout->name[suffix]) {
188 if (!strcmp(inout->name + suffix,
"+subcc")) {
192 "Invalid outpad suffix '%s'\n", inout->name);
197 if ((
unsigned)stream_idx >= n) {
199 "Invalid index was specified in output '%s', "
200 "must be a non-negative value < %d\n",
207 "An output with stream index %d was already specified\n",
217 for (
i = 0, inout = output_links; inout;
i++, inout = inout->next) {
229 for (
i = 0, inout = output_links; inout;
i++, inout = inout->next) {
269 "Output '%s' is not a video or audio output, not yet supported\n", inout->name);
274 if ((ret =
avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0)
310 if (frame_rate.
num > 0 && frame_rate.
den > 0) {
323 "Could not find PCM codec for sample format %s.\n",
365 double min_pts = DBL_MAX;
366 int stream_idx, min_pts_sink_idx = 0;
380 frame_to_free =
frame;
394 ff_dlog(avctx,
"EOF sink_idx:%d\n",
i);
400 ff_dlog(avctx,
"sink_idx:%d time:%f\n",
i, d);
405 min_pts_sink_idx =
i;
408 if (min_pts == DBL_MAX) {
413 ff_dlog(avctx,
"min_pts_sink_idx:%i\n", min_pts_sink_idx);
417 st = avctx->
streams[stream_idx];
426 frame_to_free =
NULL;
428 pkt->data =
pkt->buf->data;
429 pkt->size =
pkt->buf->size;
433 frame->ch_layout.nb_channels;
439 frame_metadata =
frame->metadata;
440 if (frame_metadata) {
459 pkt->stream_index = stream_idx;
471#define OFFSET(x) offsetof(LavfiContext, x)
473#define DEC AV_OPT_FLAG_DECODING_PARAM
483 .class_name =
"lavfi indev",
static enum AVSampleFormat sample_fmts[]
const FFInputFormat ff_lavfi_demuxer
Main libavdevice API header.
Main libavfilter public API header.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
#define AVIO_FLAG_READ
read-only
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.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
memory buffer sink API for audio and video
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_OPT_TYPE_SAMPLE_FMT
Underlying C type is enum AVSampleFormat.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
@ AV_CODEC_ID_WRAPPED_AVFRAME
Passthrough codec, AVFrames wrapped in AVPacket.
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
#define AV_PKT_FLAG_TRUSTED
The packet comes from a trusted source.
uint8_t * av_packet_pack_dictionary(const AVDictionary *dict, size_t *size)
Pack a dictionary for use in side_data.
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.
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
enum AVMediaType av_buffersink_get_type(const AVFilterContext *ctx)
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
int av_buffersink_get_format(const AVFilterContext *ctx)
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
int av_buffersink_get_h(const AVFilterContext *ctx)
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *ctx)
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
int av_buffersink_get_w(const AVFilterContext *ctx)
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.
#define AV_BUFFERSINK_FLAG_PEEK
Tell av_buffersink_get_buffer_ref() to read video/samples buffer reference, but not remove it from th...
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
char * avfilter_graph_dump(AVFilterGraph *graph, const char *options)
Dump a graph into a human-readable string representation.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
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.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
A convenience wrapper that allocates and initializes a filter in a single step.
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
#define AVERROR_EOF
End of file.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
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.
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
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.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define LIBAVUTIL_VERSION_INT
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int av_opt_set_array(void *obj, const char *name, int search_flags, unsigned int start_elem, unsigned int nb_elems, enum AVOptionType val_type, const void *val)
Add, replace, or remove elements for an array option.
static int create_subcc_streams(AVFormatContext *avctx)
static void lavfi_free_frame(void *opaque, uint8_t *data)
static av_cold int lavfi_read_close(AVFormatContext *avctx)
static av_cold int lavfi_read_header(AVFormatContext *avctx)
static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
static int create_subcc_packet(AVFormatContext *avctx, AVFrame *frame, int sink_idx)
static const AVClass lavfi_class
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
@ AV_CLASS_CATEGORY_DEVICE_INPUT
Memory handling functions.
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
This struct describes the properties of an encoded stream.
int height
The height of the video frame in pixels.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
AVRational sample_aspect_ratio
The aspect ratio (width/height) which a single pixel should have when displayed.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
A linked-list of the inputs/outputs of the filter chain.
const char * name
Filter name.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
char * url
input or output URL.
void * priv_data
Format private data.
int64_t probesize
Maximum number of bytes read from input in order to determine stream properties.
AVStream ** streams
A list of all streams in the file.
char * protocol_whitelist
',' separated list of allowed protocols.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int id
Format-specific stream ID.
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
AVRational r_frame_rate
Real base framerate of the stream.
int * sink_stream_subcc_map
#define av_malloc_array(a, b)