I am trying to get the errors from a spawn process on nodejs, trying to run FFMPEG. I have not run a child process before explicitly, so I'm not sure this is right, but what I have gathered from code examples online:
const {spawn} = require('child_process');
async function(req,res){
console.log(res.req.files.data[0].path);
var tst_loc = res.req.files.data[0].path;
try {
var the_arr = tst_loc.split('/');
the_arr.pop();
tst_loc1 = the_arr.join('/') +"/test.avi";
console.log("HERE");
var cmd = 'ffmpeg';
var tstspawn = spawn(cmd, [
'-i', tst_loc,
'-s', '800x400',
'-b:v', '64k',
'-c:v', 'avi',
'-c:a', tst_loc1,
'-o', outputfilename
], (error, stdout, stderr) => {
if (error) {
console.error('Error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:', stderr);
throw error;
}
console.log('Success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!', stdout);
})
tstspawn.stderr.on('data', function(data) {
//Here is where the error output goes
console.log('stderr: ' + data);
data=data.toString();
scriptOutput+=data;
});
tstspawn.stderr.on('error',function(error){
console.log(error);
});
} catch (e) {
console.log(e.code);
console.log(e.msg);
}
Returns only my console logs of the path data, the console log of the "HERE", and nothing else at all. I know it didn't run properly because I do not get the expected video file that FFMPEG should have output. But I can't get any sort of error message on my console. No crashing of the application or anything...
Thanks for any help,