node.jsffmpegtranscode

an error happened: spawn ENOENT, node.js & FFmpeg


I am having a nightmare of a time trying figure this out. I asked a question about this yesterday but only got so far, long story short, I cannot for the life of me figure this out.

All i want to do, is transcode a .avi file to a .flv file using FFmpeg in a node.js app, this works just using the command line for FFmpeg but not in the app, here's the code:

var ffmpeg = require('fluent-ffmpeg');

//make sure you set the correct path to your video file
var proc = new ffmpeg({ source: 'C:/Users/Jay/Documents/movie/drop.avi', nolog: true });

//Set the path to where FFmpeg is installed
proc.setFfmpegPath("C:\\Users\\Jay\\Documents\\FFMPEG\\bin");

proc
//set the size
//.withSize('50%') <-- error appears after this line

// set fps
//.withFps(24)

// set output format to force
//.toFormat('flv')

// setup event handlers
.on('end', function() {
    console.log('file has been converted successfully');
})
.on('error', function(err) {
    console.log('an error happened: ' + err.message);
})
// save to file <-- the new file I want -->
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');

The error appears on the line specified above, it's not an error with red writing, but it simply says:

an error happened: spawn ENOENT

Has anyone come across this?


Solution

  • Ben Fortune fixed the error for me, turns out I forgot to specify the ffmpeg.exe in the path to where FFmpeg was installed. Here is the updated version of the code:

    var ffmpeg = require('fluent-ffmpeg');
    
    //make sure you set the correct path to your video file
    var proc = new ffmpeg({ source: 'C:/Users/Jay/Documents/movie/drop.avi', nolog: true });
    
    //Set the path to where FFmpeg is installed
    proc.setFfmpegPath("C:\\Users\\Jay\\Documents\\FFMPEG\\bin\\ffmpeg.exe"); //I forgot to include "ffmpeg.exe"
    
    proc
    //set the size
    .withSize('50%')
    
    // set fps
    .withFps(24)
    
    // set output format to force
    .toFormat('flv')
    
    // setup event handlers
    .on('end', function() {
        console.log('file has been converted successfully');
    })
    .on('error', function(err) {
        console.log('an error happened: ' + err.message);
    })
    // save to file <-- the new file I want -->
    .saveToFile('C:/Users/Jay/Documents/movie/drop.flv');