tnfe / FFCreator

A fast video processing library based on node.js (一个基于node.js的高速视频制作库)
http://tnfe.github.io/FFCreator/
MIT License
2.83k stars 398 forks source link

请问如何提升渲染速度,122秒的视频使用955秒渲染耗时 #198

Open DZwangbing opened 2 years ago

DZwangbing commented 2 years ago

您好,向您请教一下 视频时长122秒,使用13个场景,场景中包含虚拟人、图表、背景音乐、文字,渲染耗时750秒; node和ffmpeg的cpu占用率很低,node普遍在40%以下、ffmpeg普遍在30%以下; 配置如下,请问如何降低视频渲染耗时?

环境 ubuntu 2核 2G 版本 ffmpeg v4.4-static、nodejs v16.13.1;

width: 1080,
height: 1920,
clarity: 'high',
fps: 24,
audioLoop: false,
highWaterMark: '20mb',
parallel: 8,
threads: 4
drawcall commented 2 years ago

Oh why do you need so many transitions, can you upload the project

DZwangbing commented 2 years ago

抱歉!项目比较重,不太方便拆分,视频渲染代码都是按照官方提供的方法进行使用的; 我可以提供渲染结果:[video]()

drawcall commented 2 years ago

Great video, lots of ways to speed things up. https://tnfe.github.io/FFCreator/#/guide/config

vb | 无 | string | ffmpeg vb
-- | -- | -- | --
crf | 无 | number (默认crf) | ffmpeg crf
preset | 无 | string | ffmpeg preset

You can also use animate animation without using too many transition animations

DZwangbing commented 2 years ago

非常感谢您的建议! 我会依次尝试~

DZwangbing commented 2 years ago

目前通过调整highWaterMark速度有了很大的提升; 现在对渲染耗时影响最大的还是 fillNewData (/lain/node_modules/ffcreator/lib/utils/stream.js:45:1)

1

cc @drawcall

drawcall commented 2 years ago

Oh thanks for your analysis, see http://nodejs.cn/api/stream/buffering.html

laobiao168 commented 1 month ago

我也遇到同样的问题了,合成时间需要10分钟,太慢了简直无法忍受。请问楼主怎么解决的呢

DZwangbing commented 3 weeks ago

我也遇到同样的问题了,合成时间需要10分钟,太慢了简直无法忍受。请问楼主怎么解决的呢

把每个页面都通过任务队列分配给子服务做渲染,最后主进程把多个页面做拼接