如何在节点JS上通过ffmpeg在video中添加标题

我正在开发一个项目,我必须通过FFmpeg在video上添加标题。 我已经成功地在video上添加了一张图片。 任何人都可以帮我添加文字(标题)的video?

这里是我的代码添加图片,请build议所需的修改:

try { var process = new ffmpeg('public/'+req.body.video); process.then(function (video) { console.log('The video is ready to be processed'); var watermarkPath = 'public/images/logo.png', newFilepath = 'public/videos/watermarked/'+name, settings = { position : "SC" // Position: NE NC NW SE SC SW C CE CW , margin_nord : null // Margin nord , margin_sud : null // Margin sud , margin_east : null // Margin east , margin_west : null // Margin west }; var callback = function (error, files) { if(error){ console.log('ERROR: ', error); } else{ console.log('TERMINOU', files); res.send('videos/watermarked/'+name) } } //add watermark video.fnAddWatermark(watermarkPath, newFilepath, settings, callback) }, function (err) { console.log('Error: ' + err); }); } catch (e) { console.log(e.code); console.log(e.msg); } 

command.videoFilters({filter:'drawtext',options:{fontfile:'Lucida Grande.ttf',text:'THIS IS TEXT',/ * etc. * /}});

您可以创buildcanvas,并在canvas上添加一些文本,并通过canvas获取png,并且可以在节点JS上通过ffmpeg添加video中的标题。

canvas 节点-ffmpeg