af7a1810893aa2499b2b680959a7551629db2182
2 * Copyright (c) 2009 Stefano Sabatini
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "libavformat/avformat.h"
22 #include "libavutil/pixdesc.h"
23 #include "libavfilter/avfilter.h"
25 int main(int argc
, char **argv
)
28 AVFilterContext
*filter_ctx
;
29 const char *filter_name
;
30 const char *filter_args
= NULL
;
33 av_log_set_level(AV_LOG_DEBUG
);
36 fprintf(stderr
, "Missing filter name as argument\n");
40 filter_name
= argv
[1];
42 filter_args
= argv
[2];
44 avfilter_register_all();
46 /* get a corresponding filter and open it */
47 if (!(filter
= avfilter_get_by_name(filter_name
))) {
48 fprintf(stderr
, "Unrecognized filter with name '%s'\n", filter_name
);
52 if (!(filter_ctx
= avfilter_open(filter
, NULL
))) {
53 fprintf(stderr
, "Inpossible to open filter with name '%s'\n", filter_name
);
56 if (avfilter_init_filter(filter_ctx
, filter_args
, NULL
) < 0) {
57 fprintf(stderr
, "Impossible to init filter '%s' with arguments '%s'\n", filter_name
, filter_args
);
61 /* create a link for each of the input pads */
62 for (i
= 0; i
< filter_ctx
->input_count
; i
++) {
63 AVFilterLink
*link
= av_malloc(sizeof(AVFilterLink
));
64 filter_ctx
->inputs
[i
] = link
;
66 for (i
= 0; i
< filter_ctx
->output_count
; i
++) {
67 AVFilterLink
*link
= av_malloc(sizeof(AVFilterLink
));
68 filter_ctx
->outputs
[i
] = link
;
71 if (filter
->query_formats
)
72 filter
->query_formats(filter_ctx
);
74 avfilter_default_query_formats(filter_ctx
);
76 /* print the supported formats in input */
77 for (i
= 0; i
< filter_ctx
->input_count
; i
++) {
78 AVFilterFormats
*fmts
= filter_ctx
->inputs
[i
]->out_formats
;
79 for (j
= 0; j
< fmts
->format_count
; j
++)
80 printf("INPUT[%d] %s: %s\n",
81 i
, filter_ctx
->filter
->inputs
[i
].name
,
82 av_pix_fmt_descriptors
[fmts
->formats
[j
]].name
);
85 /* print the supported formats in output */
86 for (i
= 0; i
< filter_ctx
->output_count
; i
++) {
87 AVFilterFormats
*fmts
= filter_ctx
->outputs
[i
]->in_formats
;
88 for (j
= 0; j
< fmts
->format_count
; j
++)
89 printf("OUTPUT[%d] %s: %s\n",
90 i
, filter_ctx
->filter
->outputs
[i
].name
,
91 av_pix_fmt_descriptors
[fmts
->formats
[j
]].name
);