You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.5KB

  1. /*
  2. * Copyright (c) 2009 Stefano Sabatini
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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.
  10. *
  11. * Libav 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.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdio.h>
  21. #include "libavutil/pixdesc.h"
  22. #include "libavfilter/avfilter.h"
  23. #include "libavfilter/formats.h"
  24. int main(int argc, char **argv)
  25. {
  26. AVFilter *filter;
  27. AVFilterContext *filter_ctx;
  28. AVFilterGraph *graph_ctx;
  29. const char *filter_name;
  30. const char *filter_args = NULL;
  31. int i, j;
  32. av_log_set_level(AV_LOG_DEBUG);
  33. if (!argv[1]) {
  34. fprintf(stderr, "Missing filter name as argument\n");
  35. return 1;
  36. }
  37. filter_name = argv[1];
  38. if (argv[2])
  39. filter_args = argv[2];
  40. /* allocate graph */
  41. graph_ctx = avfilter_graph_alloc();
  42. if (!graph_ctx)
  43. return 1;
  44. avfilter_register_all();
  45. /* get a corresponding filter and open it */
  46. if (!(filter = avfilter_get_by_name(filter_name))) {
  47. fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
  48. return 1;
  49. }
  50. /* open filter and add it to the graph */
  51. if (!(filter_ctx = avfilter_graph_alloc_filter(graph_ctx, filter, filter_name))) {
  52. fprintf(stderr, "Impossible to open filter with name '%s'\n",
  53. filter_name);
  54. return 1;
  55. }
  56. if (avfilter_init_str(filter_ctx, filter_args) < 0) {
  57. fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
  58. filter_name, filter_args);
  59. return 1;
  60. }
  61. /* create a link for each of the input pads */
  62. for (i = 0; i < filter_ctx->nb_inputs; i++) {
  63. AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
  64. link->type = filter_ctx->filter->inputs[i].type;
  65. filter_ctx->inputs[i] = link;
  66. }
  67. for (i = 0; i < filter_ctx->nb_outputs; i++) {
  68. AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
  69. link->type = filter_ctx->filter->outputs[i].type;
  70. filter_ctx->outputs[i] = link;
  71. }
  72. if (filter->query_formats)
  73. filter->query_formats(filter_ctx);
  74. else
  75. ff_default_query_formats(filter_ctx);
  76. /* print the supported formats in input */
  77. for (i = 0; i < filter_ctx->nb_inputs; i++) {
  78. AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
  79. for (j = 0; j < fmts->nb_formats; j++)
  80. printf("INPUT[%d] %s: %s\n",
  81. i, filter_ctx->filter->inputs[i].name,
  82. av_get_pix_fmt_name(fmts->formats[j]));
  83. }
  84. /* print the supported formats in output */
  85. for (i = 0; i < filter_ctx->nb_outputs; i++) {
  86. AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
  87. for (j = 0; j < fmts->nb_formats; j++)
  88. printf("OUTPUT[%d] %s: %s\n",
  89. i, filter_ctx->filter->outputs[i].name,
  90. av_get_pix_fmt_name(fmts->formats[j]));
  91. }
  92. avfilter_free(filter_ctx);
  93. avfilter_graph_free(&graph_ctx);
  94. fflush(stdout);
  95. return 0;
  96. }