20 const char *sink_name;
41 int main(
int argc,
char **argv)
43 char *in_graph_desc, **out_dev_name;
54 "Usage: %s filter_graph dev:out [dev2:out2...]\n\n" 56 "%s movie=file.nut:s=v+a xv:- alsa:default\n" 57 "%s movie=file.nut:s=v+a uncodedframecrc:pipe:0\n",
58 argv[0], argv[0], argv[0]);
61 in_graph_desc = argv[1];
62 out_dev_name = argv + 2;
63 nb_out_dev = argc - 2;
99 if (nb_out_dev != 1 && nb_out_dev !=
nb_streams) {
101 "Graph has %d output streams, %d devices given\n",
128 for (i = 0; i < nb_out_dev; i++) {
129 char *fmt =
NULL, *dev = out_dev_name[
i];
131 if ((dev = strchr(dev,
':'))) {
133 fmt = out_dev_name[
i];
152 streams[i].mux = streams[0].mux;
167 st->stream->avg_frame_rate =
179 st->stream->codecpar->codec_id =
av_get_pcm_codec(st->stream->codecpar->format, -1);
187 for (i = 0; i < nb_out_dev; i++) {
202 "Uncoded frames not supported on stream #%d: %s\n",
238 st->stream->time_base);
253 for (i = 0; i < nb_out_dev; i++) {
262 for (i = 0; i < nb_out_dev; i++) {
AVFilterContext ** filters
This structure describes decoded (raw) audio or video data.
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
#define AVIO_FLAG_WRITE
write-only
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index)
Test whether a muxer supports uncoded frame.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
memory buffer sink API for audio and video
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
AVFilterPad * output_pads
array of output pads
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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.
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
#define AVERROR_EOF
End of file.
static int create_sink(Stream *st, AVFilterGraph *graph, AVFilterContext *f, int idx)
int av_buffersink_get_h(const AVFilterContext *ctx)
int av_buffersink_get_format(const AVFilterContext *ctx)
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Main libavdevice API header.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
unsigned nb_outputs
number of output pads
simple assert() macros that are a bit more flexible than ISO C assert().
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.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
unsigned nb_inputs
number of input pads
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.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
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
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *ctx)
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
uint64_t av_buffersink_get_channel_layout(const AVFilterContext *ctx)
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
enum AVMediaType av_buffersink_get_type(const AVFilterContext *ctx)
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_buffersink_get_w(const AVFilterContext *ctx)
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
AVFilterLink ** outputs
array of pointers to output links
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write an uncoded frame to an output media file.
int main(int argc, char **argv)
int av_buffersink_get_channels(const AVFilterContext *ctx)
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.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
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
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
#define AV_NOPTS_VALUE
Undefined timestamp value.