var gif = require("../gifmaker"); var st = new Date().getTime() console.log('正在生成Gif'); gif.makewithfilters("../template/9564a00ec44567367a07bee43868c420a8c48e60.mp4", [ { filter: "drawtext", options: { "text": "111", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,1.18,1.56)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "222", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,3.18,4.43)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "333", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,5.31,7.43)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "444", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,7.56,9.93)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "555", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,10.06,11.56)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "666", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,11.93,13.06)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "777", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,13.81,16.31)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "888", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,18.06,19.56)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } }, { filter: "drawtext", options: { "text": "999", "x": "(w-text_w)/2", "y": "h-text_h-4", "enable": "between(t,19.59,21.60)", "fontfile": "simsun.ttc", "fontcolor": "white", "fontsize": "16" } } ] ).save("public/test.gif").on('end', function () { var tt = new Date().getTime() - st console.log(`成功生成Gif图,耗时:${tt}ms`); })