null pointer error
greggreenhaw opened this issue · comments
Version information
- fluent-ffmpeg version: 2.1.2
- ffmpeg version: ffmpeg version 4.4.2-0ubuntu0.22.04.1
- OS: Ubuntu 11.2.0-19ubuntu1
Node.js v18.17.1
Code to reproduce
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;
});
}