1

I'm using Firebase with the Cloud Functions feature and FFmpeg.

I see that FFmpeg is now included by default in the pre-installed packages, as you can see here. This way, I can use it with a spawn command like this:

 await spawn('ffmpeg', [
      '-y',
      '-i',
      tempFilePath,
      '-vf',
      'transpose=2',
      targetTempFilePath,
    ]);

and it works perfectly.

Unfortunately, when I'm trying to stabilize the video with vidstab, it seems that I have the following error:

ChildProcessError: `ffmpeg -i /tmp/1628240712871_edited.mp4 -vf vidstabdetect=result=transforms.trf -an -f null -` failed with code 1

I think it's because libvidstab is not activated with FFmpeg, as stated below:

To enable compilation of this filter, you need to configure FFmpeg with --enable-libvidstab.

Do you have any idea how I can activate/use it?

Thank you in advance

Julien
  • 231
  • 2
  • 8
  • I would say that the binary that comes default in Cloud Functions can not be modified to enable libvidstab. However, as mentioned over at the answer [here](https://stackoverflow.com/questions/42773497/can-you-call-out-to-ffmpeg-in-a-firebase-cloud-function), you can upload your own binary with the appropriate configuration to meet your needs – rsalinas Aug 10 '21 at 05:43
  • Yes, thank you, that's what I did :) – Julien Aug 11 '21 at 16:49

1 Answers1

1

For your information, I achieved to do it.

I had to upload my own binary. For that, I just downloaded a pre-compiled Debian-based Linux environment binary (here, but you can have your own anywhere else ;) ) and put it inside the functions directory. After that, I just deployed the functions, as usual.

This would result in the functions being deployed along with the binary.

I can now call my own binary with a command like this:

import { spawn } from 'child-process-promise';
...
await spawn('./ffmpeg', [
  // my commands
]);

I hope it helps ;)

Julien
  • 231
  • 2
  • 8