Unable to use ffprobe in fluent-ffmpeg

10,291

Solution 1

I think the documentation you've read is actually for 2.x rather than 1.x.

Try upgrading your fluent-ffmpeg module with npm install --save [email protected]

Solution 2

For ffprobe, similar should be done for other extensions

This way no need of ffmpeg having to be installed in os

const ffmpeg = require('fluent-ffmpeg');
var ffprobe = require('ffprobe-static');
ffmpeg.setFfprobePath(ffprobe.path);

Solution 3

Try setting the FFprobe path before calling it:

ffmpeg.setFfprobePath("c:\\program files\\ffmpeg\\bin\\ffprobe.exe");
ffmpeg.ffprobe(sourceFile.path, function(err, metadata) {
    if (err)
    {
        console.log(err);
    }
    else{
        console.log(metadata);
    }
});
Share:
10,291
GJ.
Author by

GJ.

Updated on June 04, 2022

Comments

  • GJ.
    GJ. about 2 years

    I was intended to use ffprobe function to extract video information and here is my code:

    var FFmpeg = require('fluent-ffmpeg');
    //...
    var convert_using_ffmpeg = function (source, target) {
    
        var tempfile = path.join(config.tmproot, path.basename(target));
    
        new FFmpeg({ source: source })
            .withVideoCodec('libx264')
            .withVideoBitrate('512')
            .withAudioQuality(5)
            .withAudioCodec('libmp3lame')
            .withSize('360x288')
            //.ffprobe(function(err,data) {
            //  console.dir(data);
            //})
            .toFormat('flv')
            .on('error', function (err) {
                console.log('An error occurred: ' + err.message);
            })
            .saveToFile(tempfile, function () {
                fs.rename(tempfile, target);
            });
    };
    

    The compiler simply said Object #<FfmpegCommand> has no method 'ffprobe when I execute the program. The fluent-ffmpeg API says I should add FFMPEG_PATH and FFPROBE_PATH environment variable before executing, but the fact is I could execute ffmpeg directly in command line even if it does not exist in PATH environment variable, and the node.js program runs successfully without evoking the ffprobe function. Plus the API also says ffprobe comes together with most distribution of ffmpeg, if so, how can I add ffprobe to the environment variable separately?

    I'm using fluent-ffmpeg 1.7.0 currently.

  • GJ.
    GJ. almost 10 years
    I tried but it seems that the module does not work at all after that, I can only get the output An error occurred: spawn ENOENT
  • Ben Evans
    Ben Evans almost 10 years
    Have you definetly got ffprobe in your PATH? It's not always bundled with ffmpeg.
  • GJ.
    GJ. almost 10 years
    nope, i can't find ffprobe because i only have one ffmpeg.exe, but the problem seems unrelated to ffprobe since I have commented them.
  • Ben Evans
    Ben Evans almost 10 years
    You will also need ffprobe.exe then as fluent-ffmpeg uses it to gather metadata before processing.
  • Ben Evans
    Ben Evans almost 10 years
    If this doesn't work, I'd suggest opening an issue on that actual project rather than emailing maintainers as there's a pre-huge amount of knowledge from other people using and watching the project at github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues
  • GJ.
    GJ. almost 10 years
    Thanks for your advice.
  • GJ.
    GJ. over 9 years
    thx for help but i almost forget how i solved this problem ._.
  • Daniel Lizik
    Daniel Lizik over 8 years
    I still haven't learned exactly what PATH is (I was trying to configure it w7 for an hour but didn't have any luck) and this fixed it perfectly.
  • Andrey Solera
    Andrey Solera almost 7 years
    does this answer can be aplied to a server side in node js environment? And if so how ca I can do it