0

I'm trying to use fluent-ffmpeg in firebase functions to take screenshot of uploaded video but keep on getting this error:

Error:

Error: ffprobe exited with code 1
ffprobe version N-83692-gb8a7dcbde2-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-5) 20170205
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 47.100 / 55. 47.100
  libavcodec     57. 81.100 / 57. 81.100
  libavformat    57. 66.102 / 57. 66.102
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
test/testvideo.mp4: No such file or directory

    at ChildProcess.<anonymous> (/user_code/node_modules/fluent-ffmpeg/lib/ffprobe.js:233:22)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)

Here is my code:

exports.blurOffensiveImages = functions.storage.object().onChange(event => {
  const object = event.data;
  const file = gcs.bucket(object.bucket).file(object.name);

  // Exit if this is a move or deletion event.
  if (object.resourceState === 'not_exists') {
    return console.log('This is a deletion event.');
  }

  var proc = new ffmpeg({ source:  object.name })
  .withSize('150x100')
  .takeScreenshots({
      count: 2,
      timemarks: [ '50%', '75%' ],
      filename: '%b_screenshot_%w_%i'
    }, 'test_screenshot/', function(err, filenames) {
      console.log(filenames);
      console.log('screenshots were saved');
  });

});

Can anyone help what i'm doing wrong?

Rishabh Chandel
  • 725
  • 1
  • 11
  • 28

2 Answers2

1

The probelm is specifically mentioned in the stacktrace

"test/testvideo.mp4: No such file or directory"

What you are trying to do is directly pass firebase storage path of the file to ffmpeg, whereas ffmpeg is running on the firebase system.

So in order to pass valid path to the ffmpeg, you first need to download file from the firebase storage and store it in a temp directory of firbase (since firebase only supports tmp directory) and after that pass path that of the file, which you have downloaded from the storage into tmp folder(local path), to the ffmpeg.

Since now we have passed a local path of the file to the ffmpeg which will now be available to it locally, it will be able to find the directory and do all the stuff for you.

You can also see this link for references- https://github.com/firebase/functions-samples/blob/master/generate-thumbnail/functions/index.js

Thank you

sameepsi
  • 307
  • 1
  • 6
0

This happens when ffmpeg can't access the particular folder.

This permission error occurred with me when I cloned github repo. on linux server.

After some time I deleted that repo and used FileZilla to connect to instance & transferred all files and folders.

And it worked for me.

Vikram Sapate
  • 1,087
  • 1
  • 11
  • 16