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.

108 lines
3.4KB

  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 "libavformat/avformat.h"
  22. #include "libavutil/pixdesc.h"
  23. #include "libavfilter/avfilter.h"
  24. #include "libavfilter/formats.h"
  25. #undef fprintf
  26. #undef printf
  27. int main(int argc, char **argv)
  28. {
  29. AVFilter *filter;
  30. AVFilterContext *filter_ctx;
  31. const char *filter_name;
  32. const char *filter_args = NULL;
  33. int i, j;
  34. av_log_set_level(AV_LOG_DEBUG);
  35. if (!argv[1]) {
  36. fprintf(stderr, "Missing filter name as argument\n");
  37. return 1;
  38. }
  39. filter_name = argv[1];
  40. if (argv[2])
  41. filter_args = argv[2];
  42. avfilter_register_all();
  43. /* get a corresponding filter and open it */
  44. if (!(filter = avfilter_get_by_name(filter_name))) {
  45. fprintf(stderr, "Unrecognized filter with name '%s'\n", filter_name);
  46. return 1;
  47. }
  48. if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
  49. fprintf(stderr, "Impossible to open filter with name '%s'\n",
  50. filter_name);
  51. return 1;
  52. }
  53. if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
  54. fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
  55. filter_name, filter_args);
  56. return 1;
  57. }
  58. /* create a link for each of the input pads */
  59. for (i = 0; i < filter_ctx->input_count; i++) {
  60. AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
  61. link->type = filter_ctx->filter->inputs[i].type;
  62. filter_ctx->inputs[i] = link;
  63. }
  64. for (i = 0; i < filter_ctx->output_count; i++) {
  65. AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
  66. link->type = filter_ctx->filter->outputs[i].type;
  67. filter_ctx->outputs[i] = link;
  68. }
  69. if (filter->query_formats)
  70. filter->query_formats(filter_ctx);
  71. else
  72. ff_default_query_formats(filter_ctx);
  73. /* print the supported formats in input */
  74. for (i = 0; i < filter_ctx->input_count; i++) {
  75. AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
  76. for (j = 0; j < fmts->format_count; j++)
  77. printf("INPUT[%d] %s: %s\n",
  78. i, filter_ctx->filter->inputs[i].name,
  79. av_pix_fmt_descriptors[fmts->formats[j]].name);
  80. }
  81. /* print the supported formats in output */
  82. for (i = 0; i < filter_ctx->output_count; i++) {
  83. AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
  84. for (j = 0; j < fmts->format_count; j++)
  85. printf("OUTPUT[%d] %s: %s\n",
  86. i, filter_ctx->filter->outputs[i].name,
  87. av_pix_fmt_descriptors[fmts->formats[j]].name);
  88. }
  89. avfilter_free(filter_ctx);
  90. fflush(stdout);
  91. return 0;
  92. }