test.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. var gif = require("../gifmaker");
  2. var st = new Date().getTime()
  3. console.log('正在生成Gif');
  4. gif.makewithfilters("../template/9564a00ec44567367a07bee43868c420a8c48e60.mp4",
  5. [
  6. {
  7. filter: "drawtext",
  8. options: {
  9. "text": "111",
  10. "x": "(w-text_w)/2",
  11. "y": "h-text_h-4",
  12. "enable": "between(t,1.18,1.56)",
  13. "fontfile": "simsun.ttc",
  14. "fontcolor": "white",
  15. "fontsize": "16"
  16. }
  17. },
  18. {
  19. filter: "drawtext",
  20. options: {
  21. "text": "222",
  22. "x": "(w-text_w)/2",
  23. "y": "h-text_h-4",
  24. "enable": "between(t,3.18,4.43)",
  25. "fontfile": "simsun.ttc",
  26. "fontcolor": "white",
  27. "fontsize": "16"
  28. }
  29. },
  30. {
  31. filter: "drawtext",
  32. options: {
  33. "text": "333",
  34. "x": "(w-text_w)/2",
  35. "y": "h-text_h-4",
  36. "enable": "between(t,5.31,7.43)",
  37. "fontfile": "simsun.ttc",
  38. "fontcolor": "white",
  39. "fontsize": "16"
  40. }
  41. },
  42. {
  43. filter: "drawtext",
  44. options: {
  45. "text": "444",
  46. "x": "(w-text_w)/2",
  47. "y": "h-text_h-4",
  48. "enable": "between(t,7.56,9.93)",
  49. "fontfile": "simsun.ttc",
  50. "fontcolor": "white",
  51. "fontsize": "16"
  52. }
  53. },
  54. {
  55. filter: "drawtext",
  56. options: {
  57. "text": "555",
  58. "x": "(w-text_w)/2",
  59. "y": "h-text_h-4",
  60. "enable": "between(t,10.06,11.56)",
  61. "fontfile": "simsun.ttc",
  62. "fontcolor": "white",
  63. "fontsize": "16"
  64. }
  65. },
  66. {
  67. filter: "drawtext",
  68. options: {
  69. "text": "666",
  70. "x": "(w-text_w)/2",
  71. "y": "h-text_h-4",
  72. "enable": "between(t,11.93,13.06)",
  73. "fontfile": "simsun.ttc",
  74. "fontcolor": "white",
  75. "fontsize": "16"
  76. }
  77. },
  78. {
  79. filter: "drawtext",
  80. options: {
  81. "text": "777",
  82. "x": "(w-text_w)/2",
  83. "y": "h-text_h-4",
  84. "enable": "between(t,13.81,16.31)",
  85. "fontfile": "simsun.ttc",
  86. "fontcolor": "white",
  87. "fontsize": "16"
  88. }
  89. },
  90. {
  91. filter: "drawtext",
  92. options: {
  93. "text": "888",
  94. "x": "(w-text_w)/2",
  95. "y": "h-text_h-4",
  96. "enable": "between(t,18.06,19.56)",
  97. "fontfile": "simsun.ttc",
  98. "fontcolor": "white",
  99. "fontsize": "16"
  100. }
  101. },
  102. {
  103. filter: "drawtext",
  104. options: {
  105. "text": "999",
  106. "x": "(w-text_w)/2",
  107. "y": "h-text_h-4",
  108. "enable": "between(t,19.59,21.60)",
  109. "fontfile": "simsun.ttc",
  110. "fontcolor": "white",
  111. "fontsize": "16"
  112. }
  113. }
  114. ]
  115. ).save("public/test.gif").on('end', function () {
  116. var tt = new Date().getTime() - st
  117. console.log(`成功生成Gif图,耗时:${tt}ms`);
  118. })