lavfi-showfiltfmts.c 3.3 KB

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