fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.85k stars 874 forks source link

null pointer error #1222

Open greggreenhaw opened 1 year ago

greggreenhaw commented 1 year ago

Version information

var command = ffmpeg(stream).outputOptions([ '-f s16le', '-acodec pcm_s16le', '-vn', '-ac 1', '-ar 16k', '-threads 30', '-map_metadata -1' ]) .on('progress', (progress) => { console.log('processing mp3 to raw: ' + progress.targetSize + ' KB converted'); }) .on('end',(stdout, stderr) => { console.log('processing mp3 to raw finished!',stdout, stderr); }) .on('stderr',(stderrLine){ console.log('Stderr output: ' + stderrLine); })

        .on('error', (err, stdout, stderr) => {
            console.log('processing mp3 to raw error: ' ,err, stdout, stderr);
            cb();    
        });

        var wavStream = command.pipe();

ERROR

/app/api/www/node_modules/fluent-ffmpeg/lib/processor.js:25 if (command._inputs[inputProbeIndex].isStream) { ^

TypeError: Cannot read properties of undefined (reading 'isStream') at runFfprobe (/app/api/www/node_modules/fluent-ffmpeg/lib/processor.js:25:40) at proto._prepare (/app/api/www/node_modules/fluent-ffmpeg/lib/processor.js:373:9) at proto.exec.proto.execute.proto.run (/app/api/www/node_modules/fluent-ffmpeg/lib/processor.js:431:10) at proto.writeToStream.proto.pipe.proto.stream (/app/api/www/node_modules/fluent-ffmpeg/lib/recipes.js:64:34) at Timeout._onTimeout (file:///app/api/www/oliviaai.js:174:7) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7)

Node.js v18.17.1

#######################

problem function

function runFfprobe(command) { const inputProbeIndex = 0;

if (command._inputs[inputProbeIndex].isStream) { // Don't probe input streams as this will consume them return; } command.ffprobe(inputProbeIndex, function(err, data) { command._ffprobeData = data; }); }

########################## suggested update ##########################

function runFfprobe(command) { const inputProbeIndex = 0;

if (!command || !command._inputs[inputProbeIndex] || command._inputs[inputProbeIndex].isStream) { // Don't probe input streams as this will consume them return; } command.ffprobe(inputProbeIndex, function(err, data) { command._ffprobeData = data; }); }