我正在尝试使用 firebase 函数和 ffmpeg 在 firebase 存储中的视频上添加水印, 但无论我尝试什么,它总是会退出相同的错误。
return spawn('ffmpeg', ['-i', tmpFilePath, '-vf',`drawtext="text='hello World'`, tmpFilePath]);
我也尝试过这个:
return spawn('ffmpeg', ['-i', tmpFilePath, '-i', tmpLogoPath, '-filter_complex', '"overlay=10:10"', tmpFilePath]);
控制台日志:
ChildProcessError: `ffmpeg -i /tmp/anything -vf drawtext="text='Stack Overflow' /tmp/anything` failed with code 1
at ChildProcess.<anonymous> (/workspace/node_modules/child-process-promise/lib/index.js:132:23)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.EventEmitter.emit (domain.js:506:15)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Socket.emit (events.js:315:20)
at Socket.EventEmitter.emit (domain.js:506:15)
at Pipe.<anonymous> (net.js:674:12)
at Pipe.callbackTrampoline (internal/async_hooks.js:120:14)
最佳答案
经过多次尝试,我发现如果我通过变量传递“overlay=10:10”而不是直接传递“overlay=10:10”,则此代码对我有用。
var str = "overlay=10:10"
return spawn('ffmpeg', ['-i', tmpFilePath, '-i', tmpLogoPath, '-filter_complex', str, tmpFilePath]);
关于node.js - ffmpeg 在 ChildProcess 失败,代码为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65648316/