00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "libavformat/avformat.h"
00022 #include "libavutil/pixdesc.h"
00023 #include "libavfilter/avfilter.h"
00024
00025 int main(int argc, char **argv)
00026 {
00027 AVFilter *filter;
00028 AVFilterContext *filter_ctx;
00029 const char *filter_name;
00030 const char *filter_args = NULL;
00031 int i, j;
00032
00033 av_log_set_level(AV_LOG_DEBUG);
00034
00035 if (!argv[1]) {
00036 fprintf(stderr, "Missing filter name as argument\n");
00037 return 1;
00038 }
00039
00040 filter_name = argv[1];
00041 if (argv[2])
00042 filter_args = argv[2];
00043
00044 avfilter_register_all();
00045
00046
00047 if (!(filter = avfilter_get_by_name(filter_name))) {
00048 fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
00049 return 1;
00050 }
00051
00052 if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
00053 fprintf(stderr, "Inpossible to open filter with name '%s'\n", filter_name);
00054 return 1;
00055 }
00056 if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
00057 fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n", filter_name, filter_args);
00058 return 1;
00059 }
00060
00061
00062 for (i = 0; i < filter_ctx->input_count; i++) {
00063 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
00064 link->type = filter_ctx->filter->inputs[i].type;
00065 filter_ctx->inputs[i] = link;
00066 }
00067 for (i = 0; i < filter_ctx->output_count; i++) {
00068 AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
00069 link->type = filter_ctx->filter->outputs[i].type;
00070 filter_ctx->outputs[i] = link;
00071 }
00072
00073 if (filter->query_formats)
00074 filter->query_formats(filter_ctx);
00075 else
00076 avfilter_default_query_formats(filter_ctx);
00077
00078
00079 for (i = 0; i < filter_ctx->input_count; i++) {
00080 AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
00081 for (j = 0; j < fmts->format_count; j++)
00082 printf("INPUT[%d] %s: %s\n",
00083 i, filter_ctx->filter->inputs[i].name,
00084 av_get_pix_fmt_name(fmts->formats[j]));
00085 }
00086
00087
00088 for (i = 0; i < filter_ctx->output_count; i++) {
00089 AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
00090 for (j = 0; j < fmts->format_count; j++)
00091 printf("OUTPUT[%d] %s: %s\n",
00092 i, filter_ctx->filter->outputs[i].name,
00093 av_get_pix_fmt_name(fmts->formats[j]));
00094 }
00095
00096 avfilter_free(filter_ctx);
00097 fflush(stdout);
00098 return 0;
00099 }