Go to the documentation of this file.
22 const char *sink_name;
43 int main(
int argc,
char **argv)
45 char *in_graph_desc, **out_dev_name;
56 "Usage: %s filter_graph dev:out [dev2:out2...]\n\n"
58 "%s movie=file.nut:s=v+a xv:- alsa:default\n"
59 "%s movie=file.nut:s=v+a uncodedframecrc:pipe:0\n",
60 argv[0], argv[0], argv[0]);
63 in_graph_desc = argv[1];
64 out_dev_name = argv + 2;
65 nb_out_dev = argc - 2;
85 for (j = 0; j <
f->nb_inputs; j++) {
92 for (j = 0; j <
f->nb_outputs; j++)
101 if (nb_out_dev != 1 && nb_out_dev !=
nb_streams) {
103 "Graph has %d output streams, %d devices given\n",
116 for (j = 0; j <
f->nb_outputs; j++) {
117 if (!
f->outputs[j]) {
130 for (
i = 0;
i < nb_out_dev;
i++) {
131 char *fmt =
NULL, *dev = out_dev_name[
i];
133 if ((dev = strchr(dev,
':'))) {
135 fmt = out_dev_name[
i];
154 streams[
i].mux = streams[0].mux;
169 st->stream->avg_frame_rate =
182 st->stream->codecpar->codec_id =
av_get_pcm_codec(st->stream->codecpar->format, -1);
190 for (
i = 0;
i < nb_out_dev;
i++) {
205 "Uncoded frames not supported on stream #%d: %s\n",
241 st->stream->time_base);
256 for (
i = 0;
i < nb_out_dev;
i++) {
265 for (
i = 0;
i < nb_out_dev;
i++) {
#define AV_LOG_WARNING
Something somehow does not look correct.
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *ctx)
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 struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
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.
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.
int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index)
Test whether a muxer supports uncoded frame.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
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.
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
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
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.
#define AVIO_FLAG_WRITE
write-only
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
AVFilterContext ** filters
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
static int create_sink(Stream *st, AVFilterGraph *graph, AVFilterContext *f, int idx)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
#define AV_NOPTS_VALUE
Undefined timestamp value.
enum AVMediaType av_buffersink_get_type(const AVFilterContext *ctx)
int av_buffersink_get_w(const AVFilterContext *ctx)
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
#define i(width, name, range_min, range_max)
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.
void * av_calloc(size_t nmemb, size_t size)
int av_buffersink_get_h(const AVFilterContext *ctx)
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
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
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
int main(int argc, char **argv)
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
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.
int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, struct AVFrame *frame)
Write an uncoded frame to an output media file.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
FF_VISIBILITY_POP_HIDDEN av_cold void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.