21 const char *sink_name;
43 int main(
int argc,
char **argv)
45 char *in_graph_desc, **out_dev_name;
50 int i, j,
run = 1, ret;
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;
103 if (nb_out_dev != 1 && nb_out_dev !=
nb_streams) {
105 "Graph has %d output streams, %d devices given\n",
132 for (i = 0; i < nb_out_dev; i++) {
133 char *
fmt =
NULL, *dev = out_dev_name[i];
135 if ((dev = strchr(dev,
':'))) {
137 fmt = out_dev_name[i];
156 streams[i].mux = streams[0].mux;
166 st->stream->codec->codec_type = st->link->type;
167 st->stream->time_base = st->stream->codec->time_base =
169 switch (st->link->type) {
172 st->stream->avg_frame_rate =
174 st->stream->codec->width = st->link->w;
175 st->stream->codec->height = st->link->h;
176 st->stream->codec->sample_aspect_ratio = st->link->sample_aspect_ratio;
177 st->stream->codec->pix_fmt = st->link->format;
180 st->stream->codec->channel_layout = st->link->channel_layout;
182 st->stream->codec->sample_rate = st->link->sample_rate;
183 st->stream->codec->sample_fmt = st->link->format;
184 st->stream->codec->codec_id =
193 for (i = 0; i < nb_out_dev; i++) {
208 "Uncoded frames not supported on stream #%d: %s\n",
243 st->link ->time_base,
244 st->stream->time_base);
251 "Error writing frame: %s\n",
av_err2str(ret));
259 for (i = 0; i < nb_out_dev; i++) {
268 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 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.
void avfilter_register_all(void)
Initialize the filter system.
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.
#define AVERROR_EOF
End of file.
static int create_sink(Stream *st, AVFilterGraph *graph, AVFilterContext *f, int idx)
#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.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int avfilter_link_get_channels(AVFilterLink *link)
Get the number of channels of a link.
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...
enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
Return the PCM codec associated with a sample format.
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
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.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
AVFilterLink ** outputs
array of pointers to output links
AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx)
Get the frame rate of the input.
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 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.
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
#define AV_NOPTS_VALUE
Undefined timestamp value.