ERROR : “Cannot Find FFMPEG” on Google Cloud Compu

2019-09-18 11:03发布

问题:

I wrote a Node.JS application that uses the fluent-ffmpeg module to watermark videos uploaded on the platform. I pushed the code to a my Google Cloud Compute Engine project, and every time I get Error : Cannot Find FFMPEG. I ssh'd into the instance once it was created and ran these commands to install FFMPEG before actually testing out the code. I am not sure what is causing the error because after this I am positive that FFMPEG is installed.

sudo apt-get update
sudo apt-get install -y ffmpeg
export FFMPEG_PATH="/usr/bin/ffmpeg"
export FFPROBE_PATH="/usr/bin/ffprobe"

Below is my FFMPEG code

function generate_thumbnail(name, path){
  logging.info("Generating Thumbnail");
  ffmpeg(path)
   .setFfmpegPath('/usr/bin/ffmpeg') 
   .setFfprobePath('/usr/bin/ffprobe')
   .on('end', function() {
        upload_thumbnail(name);
        logging.info("Thumbnail Generated and uploaded");
        return;
    })
  .on('error', function(err, stdout, stderr) {
        logging.info('ERROR: ' + err.message);
        logging.info('STDERR:' + stderr);
  })
  .on('start', function(commandLine) {
       logging.info(commandLine);
  })
  .screenshots({
    count: 1,
    filename: name + '_thumbnail.png',
    folder: 'public/images/thumbnails/'
  });
}

回答1:

Can you execute /usr/bin/ffmpeg from the shell to verify if it's the correct path?

Also you can set path to the FFMPEG binary manually with setFfmpegPath method.