node.js - ffmpeg 在 ChildProcess 失败,代码为 1

标签 node.js firebase ffmpeg google-cloud-functions child-process

我正在尝试使用 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/

相关文章:

javascript - 使用 Node 运行程序时检查是否给出 ARGV

javascript - 如何将我本地的 webhook 连接到 dialogflow?

javascript - 我有一个 this.state ,我需要用 setState 传入我的 componentDidMount ,如何在 setState 中使用 bind(this) ?

javascript - promise 的嵌套 while 循环

javascript - 如何使用node获取给定url的所有元素的css?

swift - 无密码电子邮件身份验证 Firebase、动态链接 (FDL)

FFMPEG 将两个命令合二为一

python - FFmpeg concat demuxer 不工作 : No error, 并且没有输出

ffmpeg - 如何获得 ffmpeg 的 colorchannelmixer 的颜色矩阵

node.js - 与 nodejs express 共享 laravel 4 session