Open YIyiyi-3 opened 1 year ago
// 入口 const creator = new FFCreator({ cacheDir: path.join(dirname, “../cache/”), // 缓存目录 outputDir: path.join(dirname, “../public/videos/”), // 输出目录 output: new Date().getTime() + ".mp4", width, // 影片宽 height, // 影片高 cover: cover || null, // 设置封面 audioLoop, // 音乐循环 fps, // fps threads: 4, // 多线程(伪造)并行渲染 // debug: false, // 开启测试模式 // defaultOutputOptions: null, // ffmpeg输出选项配置 });
creator.start(); // 开始加工 // creator.closeLog(); // 关闭log(包含perf) creator.on("start", () => { console.log(FFCreator start); }); creator.on("error", (e) => { console.log(FFCreator error: ${JSON.stringify(e)}); }); creator.on("progress", (e) => { console.log(FFCreator progress: ${e.state} ${(e.percent * 100) >> 0}%); }); creator.on("complete", (e) => { console.log( FFCreator completed: \n USEAGE: ${e.useage} \n PATH: ${pathReslove( "../public/resource/videos" )}/${e.output} ); fs.rename( pathReslove("../") + e.output, pathReslove("../public/videos/" + e.output), (err) => { console.log(err); if (!err) { console.log("修改成功"); } } ); resolve("/videos/" + e.output); });
FFCreator start
FFCreator error: ${JSON.stringify(e)}
FFCreator progress: ${e.state} ${(e.percent * 100) >> 0}%
FFCreator completed: \n USEAGE: ${e.useage} \n PATH: ${pathReslove( "../public/resource/videos" )}/${e.output}
已经解决 设置output output: path.join( __dirname, "../public/videos/", new Date().getTime() + ".mp4" ),
// 入口 const creator = new FFCreator({ cacheDir: path.join(dirname, “../cache/”), // 缓存目录 outputDir: path.join(dirname, “../public/videos/”), // 输出目录 output: new Date().getTime() + ".mp4", width, // 影片宽 height, // 影片高 cover: cover || null, // 设置封面 audioLoop, // 音乐循环 fps, // fps threads: 4, // 多线程(伪造)并行渲染 // debug: false, // 开启测试模式 // defaultOutputOptions: null, // ffmpeg输出选项配置 });
creator.start(); // 开始加工 // creator.closeLog(); // 关闭log(包含perf) creator.on("start", () => { console.log(
FFCreator start
); }); creator.on("error", (e) => { console.log(FFCreator error: ${JSON.stringify(e)}
); }); creator.on("progress", (e) => { console.log(FFCreator progress: ${e.state} ${(e.percent * 100) >> 0}%
); }); creator.on("complete", (e) => { console.log(FFCreator completed: \n USEAGE: ${e.useage} \n PATH: ${pathReslove( "../public/resource/videos" )}/${e.output}
); fs.rename( pathReslove("../") + e.output, pathReslove("../public/videos/" + e.output), (err) => { console.log(err); if (!err) { console.log("修改成功"); } } ); resolve("/videos/" + e.output); });