• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

tools/lavfi-showfiltfmts.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009 Stefano Sabatini
00003  *
00004  * This file is part of Libav.
00005  *
00006  * Libav is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * Libav is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with Libav; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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     /* get a corresponding filter and open it */
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     /* create a link for each of the input pads */
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     /* print the supported formats in input */
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_pix_fmt_descriptors[fmts->formats[j]].name);
00085     }
00086 
00087     /* print the supported formats in output */
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_pix_fmt_descriptors[fmts->formats[j]].name);
00094     }
00095 
00096     avfilter_free(filter_ctx);
00097     fflush(stdout);
00098     return 0;
00099 }
Generated on Thu Jan 24 2013 17:08:56 for Libav by doxygen 1.7.1