Go to the documentation of this file.
228 uint32_t *pal, *dst2;
236 if (
r->x < 0 ||
r->x +
r->w >
w ||
r->y < 0 ||
r->y +
r->h >
h) {
238 r->x,
r->y,
r->w,
r->h,
w,
h
243 dst +=
r->y * dst_linesize +
r->x * 4;
245 pal = (uint32_t *)
r->data[1];
246 for (y = 0; y <
r->h; y++) {
247 dst2 = (uint32_t *)dst;
249 for (x = 0; x <
r->w; x++)
250 *(dst2++) = pal[*(
src2++)];
252 src +=
r->linesize[0];
278 int64_t
pts, end_pts;
298 "Impossible to get a blank canvas.\n");
303 for (
i = 0;
i < num_rects;
i++)
342 #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \
343 static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
345 if (ofp->var == none && !ofp->supported_list) \
347 av_bprintf(bprint, #name "="); \
348 if (ofp->var != none) { \
349 av_bprintf(bprint, printf_format, get_name(ofp->var)); \
353 for (p = ofp->supported_list; *p != none; p++) { \
354 av_bprintf(bprint, printf_format "|", get_name(*p)); \
356 if (bprint->len > 0) \
357 bprint->str[--bprint->len] = '\0'; \
359 av_bprint_chars(bprint, ':', 1); \
376 }
else if (ofp->ch_layouts) {
385 bprint->str[--bprint->len] =
'\0';
408 if (fsize < 0 || fsize > INT_MAX) {
484 "Error applying option '%s' to filter '%s': %s\n",
489 "Error loading value for option '%s' from file '%s'\n",
543 if (!
f->hw_device_ctx) {
577 int nb_pads = in ?
ctx->nb_inputs :
ctx->nb_outputs;
639 if (!
c->ch_layouts) {
647 for (
i = 0;
c->ch_layouts[
i].nb_channels;
i++) {
648 if (
c->ch_layouts[
i].nb_channels ==
ost->enc_ctx->ch_layout.nb_channels)
651 if (
c->ch_layouts[
i].nb_channels) {
681 switch (
ost->enc_ctx->codec_type) {
694 if (!strcmp(
c->name,
"mjpeg")) {
702 int strict_val =
ost->enc_ctx->strict_std_compliance;
724 NULL :
c->supported_framerates;
739 if (
ost->enc_ctx->sample_rate) {
744 if (
ost->enc_ctx->ch_layout.nb_channels) {
748 }
else if (
c->ch_layouts) {
810 for (
int j = 0; j < fg->
nb_inputs; j++) {
916 if (!ifilter->
name) {
934 if (!ofilter->
name) {
977 "to have exactly 1 input and 1 output. "
978 "However, it had %d input(s) and %d output(s). Please adjust, "
979 "or use a complex filtergraph (-filter_complex) instead.\n",
1016 int file_idx = strtol(ifp->
linklabel, &p, 0);
1025 for (
i = 0;
i <
s->nb_streams;
i++) {
1026 enum AVMediaType stream_type =
s->streams[
i]->codecpar->codec_type;
1027 if (stream_type !=
type &&
1038 "matches no streams.\n", p, fgp->
graph_desc);
1046 "unlabeled input pad %s\n", ifilter->
name);
1055 "Error binding an input stream to complex filtergraph input %s.\n",
1076 const char *filter_name)
1091 "recording time.\n",
name);
1126 const char *filter_name,
const char *args)
1134 filter_name, args,
NULL, graph);
1154 int pad_idx =
out->pad_idx;
1172 snprintf(args,
sizeof(args),
"%d:%d",
1215 &last_filter, &pad_idx,
name);
1232 int pad_idx =
out->pad_idx;
1246 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
1247 AVFilterContext *filt_ctx; \
1249 av_log(fg, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
1250 "similarly to -af " filter_name "=%s.\n", arg); \
1252 ret = avfilter_graph_create_filter(&filt_ctx, \
1253 avfilter_get_by_name(filter_name), \
1254 filter_name, arg, NULL, fg->graph); \
1258 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
1262 last_filter = filt_ctx; \
1266 #if FFMPEG_OPT_MAP_CHANNEL
1267 if (
ost->audio_channels_mapped) {
1272 for (
i = 0;
i <
ost->audio_channels_mapped;
i++)
1273 if (
ost->audio_channels_map[
i] != -1)
1281 choose_sample_fmts(ofp, &args);
1282 choose_sample_rates(ofp, &args);
1322 &last_filter, &pad_idx,
name);
1337 if (!ofilter->
ost) {
1358 "Filter %s has an unconnected output\n",
output->name);
1392 int ret, pad_idx = 0;
1393 int64_t tsoffset = 0;
1398 memset(par, 0,
sizeof(*par));
1421 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
1422 "pixel_aspect=%d/%d",
1439 last_filter = ifp->
filter;
1458 if (
fabs(theta - 90) < 1.0) {
1460 displaymatrix[3] > 0 ?
"cclock_flip" :
"clock");
1461 }
else if (
fabs(theta - 180) < 1.0) {
1462 if (displaymatrix[0] < 0) {
1467 if (displaymatrix[4] < 0) {
1470 }
else if (
fabs(theta - 270) < 1.0) {
1472 displaymatrix[3] < 0 ?
"clock_flip" :
"cclock");
1473 }
else if (
fabs(theta) > 1.0) {
1474 char rotate_buf[64];
1475 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
1477 }
else if (
fabs(theta) < 1.0) {
1478 if (displaymatrix && displaymatrix[4] < 0) {
1491 tsoffset +=
f->ctx->start_time;
1495 &last_filter, &pad_idx,
name);
1518 int ret, pad_idx = 0;
1519 int64_t tsoffset = 0;
1529 av_bprintf(&args,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
1546 last_filter = ifp->
filter;
1553 tsoffset +=
f->ctx->start_time;
1557 &last_filter, &pad_idx,
name);
1589 return f->nb_inputs == 0 &&
1590 (!strcmp(
f->filter->name,
"buffer") ||
1591 !strcmp(
f->filter->name,
"abuffer"));
1604 f->nb_outputs == 0 ||
1704 fr.
num > 0 && fr.
den > 0)
1819 const char *command,
const char *
arg,
int all_filters)
1827 char response[4096];
1829 response,
sizeof(response),
1831 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s",
1833 }
else if (!all_filters) {
1834 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
1838 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(
ret));
1856 "Demuxing timebase not available - cannot use it for encoding\n");
1875 if (fr_sink.
num > 0 && fr_sink.
den > 0)
1884 "about the input framerate is available. Falling "
1885 "back to a default value of 25fps. Use the -r option "
1886 "if you want a different framerate.\n");
1906 if (!(
tb.num > 0 &&
tb.den > 0))
1908 if (!(
tb.num > 0 &&
tb.den > 0))
1938 if (float_pts !=
llrint(float_pts))
1939 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
1951 float_pts, tb_dst.
num, tb_dst.
den);
1962 int64_t *nb_frames, int64_t *nb_frames_prev)
1987 delta0 = sync_ipts - ofp->
next_pts;
1992 *nb_frames_prev = 0;
2000 if (delta0 < -0.6) {
2009 switch (
ost->vsync_method) {
2021 }
else if (
delta < -1.1)
2023 else if (
delta > 1.1) {
2026 *nb_frames_prev =
llrintf(delta0 - 0.6);
2033 else if (
delta > 0.6)
2055 "*** dropping frame %"PRId64
" at ts %"PRId64
"\n",
2058 if (*nb_frames > (*nb_frames_prev && fps->
last_dropped) + (*nb_frames > *nb_frames_prev)) {
2084 int64_t nb_frames = 1, nb_frames_prev = 0;
2089 for (int64_t
i = 0;
i < nb_frames;
i++) {
2094 AVFrame *frame_in = (
i < nb_frames_prev && frame_prev->
buf[0]) ?
2134 if (
i == nb_frames_prev &&
frame)
2141 if (
frame && frame_prev) {
2163 return (
ret < 0) ?
ret : 1;
2166 }
else if (
ret < 0) {
2168 "Error in retrieving a frame from the filtergraph: %s\n",
2172 if (
ost->finished) {
2213 if (fr.
num > 0 && fr.
den > 0)
2261 if (pts2 <= ifp->sub2video.last_pts)
2346 "Cannot determine format of input stream %d:%d after EOF\n",
2360 int need_reinit,
ret;
2365 switch (ifp->
type) {
2397 if (need_reinit || !fg->
graph) {
2423 if (keep_reference) {
2434 #if LIBAVUTIL_VERSION_MAJOR < 59
2456 int nb_requests, nb_requests_max = 0;
2459 if (!graph->
graph) {
2464 *best_ist = ifp->
ist;
2516 "No filtered frames for output stream, trying to "
2517 "initialize anyway.\n");
2538 if (nb_requests > nb_requests_max) {
2539 nb_requests_max = nb_requests;
static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
int init_complex_filtergraph(FilterGraph *fg)
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
AVPixelFormat
Pixel format.
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *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 default minimum maximum flags name is the option name
struct FilterGraph * graph
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
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
double get_rotation(const int32_t *displaymatrix)
enum AVMediaType codec_type
General type of the encoded data.
int nb_threads
Maximum number of threads used by filters in this graph.
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
void close_output_stream(OutputStream *ost)
int avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags)
Create filters specified in a graph segment.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
int sample_rate
samples per second
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
static enum AVSampleFormat sample_fmts[]
int64_t duration
Duration of the frame, in the same units as pts.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
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.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
float frame_drop_threshold
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
char * av_asprintf(const char *fmt,...)
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
void fg_free(FilterGraph **pfg)
int64_t frames_prev_hist[3]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int64_t start_time
start time in microseconds == AV_TIME_BASE units
This structure describes decoded (raw) audio or video data.
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
int check_filter_outputs(void)
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec)
Set up fallback filtering parameters from a decoder context.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_NOWARN_DEPRECATED(code)
Disable warnings about deprecated features This is useful for sections of code kept for backward comp...
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
static OutputFilterPriv * ofp_from_ofilter(OutputFilter *ofilter)
enum AVChannelOrder order
Channel order used in this layout.
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
int nb_channels
Number of channels in this layout.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int64_t avio_size(AVIOContext *s)
Get the filesize.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
static int choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint, const char **dst)
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
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.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
int enc_open(OutputStream *ost, const AVFrame *frame)
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.
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
AVChannelLayout ch_layout
Audio channel layout.
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
static void sub2video_push_ref(InputFilterPriv *ifp, int64_t pts)
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
void avfilter_graph_segment_free(AVFilterGraphSegment **seg)
Free the provided AVFilterGraphSegment and everything associated with it.
static int sub2video_get_blank_frame(InputFilterPriv *ifp)
#define AV_BPRINT_SIZE_AUTOMATIC
static int ifilter_has_all_input_formats(FilterGraph *fg)
static double val(void *priv, double ch)
AVChannelLayout ch_layout
Channel layout of the audio data.
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
int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str, int flags, AVFilterGraphSegment **seg)
Parse a textual filtergraph description into an intermediate form.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
static int graph_is_meta(AVFilterGraph *graph)
void ifilter_sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational tb)
static FilterGraphPriv * fgp_from_fg(FilterGraph *fg)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
A filter pad used for either input or output.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
AVRational frame_rate_filter
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
static InputFilter * ifilter_alloc(FilterGraph *fg)
AVFilterParams ** filters
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
static int fg_output_frame(OutputFilterPriv *ofp, AVFrame *frame)
static OutputFilter * ofilter_alloc(FilterGraph *fg)
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int av_buffersink_get_format(const AVFilterContext *ctx)
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static enum AVPixelFormat pix_fmts[]
struct OutputStream * ost
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int64_t pts
Same as packet pts, in AV_TIME_BASE.
static int graph_opts_apply(AVFilterGraphSegment *seg)
int fg_transcode_step(FilterGraph *graph, InputStream **best_ist)
Perform a step of transcoding for the specified filter graph.
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.
int nb_coded_side_data
Amount of entries in coded_side_data.
static int64_t fsize(FILE *f)
static const char * fg_item_name(void *obj)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
const AVChannelLayout * ch_layouts
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
Describe the class of an AVClass context structure.
static __device__ float fabs(float a)
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 avfilter_graph_segment_apply(AVFilterGraphSegment *seg, int flags, AVFilterInOut **inputs, AVFilterInOut **outputs)
Apply all filter/link descriptions from a graph segment to the associated filtergraph.
int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int search_flags)
AVChannelLayout ch_layout
Parameters describing a filter to be created in a filtergraph.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
AVFilterContext * filter
The filter context.
Rational number (pair of numerator and denominator).
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
AVFilterContext ** filters
static int filter_opt_apply(AVFilterContext *f, const char *key, const char *val)
AVRational sample_aspect_ratio
static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
AVFilterChain ** chains
A list of filter chain contained in this segment.
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 inputs
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
@ AV_CLASS_CATEGORY_FILTER
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
A parsed representation of a filtergraph segment.
int pad_idx
index of the filt_ctx pad to use for linking
int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
Close the buffer source after EOF.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
int filtergraph_is_simple(const FilterGraph *fg)
int ifilter_sub2video(InputFilter *ifilter, const AVFrame *frame)
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
@ AV_BUFFERSRC_FLAG_PUSH
Immediately push the frame to the output.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
An AVChannelLayout holds information about the channel layout of audio data.
static int init_input_filter(FilterGraph *fg, InputFilter *ifilter)
AVBufferSrcParameters * av_buffersrc_parameters_alloc(void)
Allocate a new AVBufferSrcParameters instance.
AVFilterContext * filter_ctx
filter context associated to this input/output
OutputFile ** output_files
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int sample_rate
Sample rate of the audio data.
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
AVBufferRef * hw_frames_ctx
Video with a hwaccel pixel format only.
static int64_t start_time
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
static double adjust_frame_pts_to_encoder_tb(AVFrame *frame, AVRational tb_dst, int64_t start_time)
enum AVSampleFormat sample_fmt
audio sample format
static int insert_trim(int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
static int graph_parse(AVFilterGraph *graph, const char *desc, AVFilterInOut **inputs, AVFilterInOut **outputs, AVBufferRef *hw_device)
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts)
Queue a command for one or more filter instances.
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVRational time_base
Time base for the timestamps in this frame.
static int read_binary(const char *path, uint8_t **data, int *len)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
uint32_t end_display_time
void * allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
Atomically add a new element to an array of pointers, i.e.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static int filter_is_buffersrc(const AVFilterContext *f)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
#define AV_LOG_INFO
Standard information.
static int configure_filtergraph(FilterGraph *fg)
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int av_find_nearest_q_idx(AVRational q, const AVRational *q_list)
Find the value in a list of rationals nearest a given reference rational.
int av_buffersink_get_w(const AVFilterContext *ctx)
int nb_samples
number of audio samples (per channel) described by this frame
int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
Initialize the buffersrc or abuffersrc filter with the provided parameters.
@ AV_BUFFERSRC_FLAG_KEEP_REF
Keep a reference to the frame.
static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
#define i(width, name, range_min, range_max)
static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
void fg_send_command(FilterGraph *fg, double time, const char *target, const char *command, const char *arg, int all_filters)
int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Add a frame to the buffer source.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
AVSampleFormat
Audio sample formats.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
static const FilterGraphPriv * cfgp_from_cfg(const FilterGraph *fg)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
attribute_deprecated int64_t pkt_duration
duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb)
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
FilterGraph ** filtergraphs
const AVIOInterruptCB int_cb
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int av_buffersink_get_h(const AVFilterContext *ctx)
static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, int64_t *nb_frames, int64_t *nb_frames_prev)
static InputFilterPriv * ifp_from_ifilter(InputFilter *ifilter)
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
int reap_filters(FilterGraph *fg, int flush)
Get and encode new output from specified filtergraph, without causing activity.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int av_opt_eval_int(void *obj, const AVOption *o, const char *val, int *int_out)
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
static int insert_filter(AVFilterContext **last_filter, int *pad_idx, const char *filter_name, const char *args)
AVDictionary * opts
Options to be apllied to the filter.
static void choose_channel_layouts(OutputFilterPriv *ofp, AVBPrint *bprint)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
main external API structure.
int index
stream index in AVFormatContext
#define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name)
This structure contains the parameters describing the frames that will be passed to this filter.
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
int format
video: the pixel format, value corresponds to enum AVPixelFormat audio: the sample format,...
static char * describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
static const AVFilterPad outputs[]
A filterchain is a list of filter specifications.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int choose_out_timebase(OutputFilterPriv *ofp, AVFrame *frame)
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, AVSubtitleRect *r)
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
static void cleanup_filtergraph(FilterGraph *fg)
#define AVIO_FLAG_READ
read-only
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate a string.
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc)
unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
Get the number of failed requests.
void(* flush)(AVBSFContext *ctx)
A reference to a data buffer.
int auto_conversion_filters
static int fg_output_step(OutputFilterPriv *ofp, int flush)
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...
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
static const AVClass fg_class
int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep)
Get dictionary entries as a string.
char * file_read(const char *filename)
int width
picture width / height.
static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, const AVSubtitle *sub)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
Send a command to one or more filter instances.
float dts_error_threshold
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
AVBufferRef * hw_device_for_filter(void)
Get a hardware device to be used with this filtergraph.
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
A linked-list of the inputs/outputs of the filter chain.
int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference)
int fg_create(FilterGraph **pfg, char *graph_desc)
Create a new filtergraph in the global filtergraph list.
int enc_frame(OutputStream *ost, AVFrame *frame)
InputStream * ist_find_unused(enum AVMediaType type)
Find an unused input stream of given type.
static void sub2video_prepare(InputFilterPriv *ifp)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
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.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
uint32_t start_display_time
static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int filter_complex_nbthreads
const AVRational * framerate_supported