Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

93 řádky
2.1 KiB

  1. /*
  2. * makemovie read image names from stdin and create a movie
  3. * Copyright (c) 2009 Sam Hocevar <sam@hocevar.net>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #include "config.h"
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include <pipi.h>
  19. #define WIDTH 1280
  20. #define HEIGHT 720
  21. int main(int argc, char *argv[])
  22. {
  23. char file[1024];
  24. pipi_image_t *image;
  25. pipi_sequence_t *seq;
  26. pipi_pixels_t *p;
  27. int width, height, fps, par_num, par_den, bitrate;
  28. int f;
  29. width = 1280;
  30. height = 720;
  31. fps = 30;
  32. par_num = 1;
  33. par_den = 1;
  34. bitrate = 16 * 1024 * 1024;
  35. if(argc < 2)
  36. {
  37. fprintf(stderr, "usage: makemovie FILE [width [height [fps [par_num [par_den [bitrate]]]]]]>\n");
  38. return EXIT_FAILURE;
  39. }
  40. if (argc > 2)
  41. width = atoi(argv[2]);
  42. if (argc > 3)
  43. height = atoi(argv[3]);
  44. if (argc > 4)
  45. fps = atoi(argv[4]);
  46. if (argc > 5)
  47. par_num = atoi(argv[5]);
  48. if (argc > 6)
  49. par_den = atoi(argv[6]);
  50. if (argc > 7)
  51. bitrate = atoi(argv[7]);
  52. seq = pipi_open_sequence(argv[1], width, height, 0 /* YUV */, fps,
  53. par_num, par_den, bitrate);
  54. if(!seq)
  55. return EXIT_FAILURE;
  56. for(f = 0; ; f++)
  57. {
  58. uint8_t *start;
  59. int w = 0, h = 0;
  60. if(!fgets(file, sizeof(file), stdin))
  61. break;
  62. file[strlen(file) - 1] = '\0';
  63. image = pipi_load(file);
  64. if(!image)
  65. return EXIT_FAILURE;
  66. p = pipi_get_pixels(image, PIPI_PIXELS_RGBA_U8);
  67. start = (uint8_t *)p->pixels;
  68. pipi_feed_sequence(seq, start, p->w, p->h);
  69. pipi_free(image);
  70. fprintf(stderr, "frame %d\r", f);
  71. }
  72. fprintf(stderr, "\n");
  73. pipi_close_sequence(seq);
  74. return EXIT_SUCCESS;
  75. }