Search code examples
node.jsfirebaseffmpeggoogle-cloud-functionschild-process

ffmpwg failed with code 1 at ChildProcess


I am trying to add a watermark over the a video in firebase storage using firebase functions and ffmpeg, but no matter what I try it always exit the same error.

 return spawn('ffmpeg', ['-i', tmpFilePath, '-vf',`drawtext="text='hello World'`, tmpFilePath]);

And I tried this as well:

        return spawn('ffmpeg', ['-i', tmpFilePath, '-i', tmpLogoPath, '-filter_complex', '"overlay=10:10"', tmpFilePath]);

console log:

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)

Solution

  • After many tries, I found that this will work if I passed the "overlay=10:10" through a variable and not directly, this code worked for me.

    var str = "overlay=10:10"
    return spawn('ffmpeg', ['-i', tmpFilePath, '-i', tmpLogoPath, '-filter_complex', str, tmpFilePath]);