Error: ffmpeg was killed with signal SIGINT at ChildProcess.<anonymous>

67 Views Asked by At

i have an issue with fluent-ffmpeg , i was trying to record a from a stream link using node js when i start recording it works fine , but when i want to stop it , it crashs with this error :

Error: Error: ffmpeg was killed with signal SIGINT
   at ChildProcess.<anonymous> (C:\path\node_modules\fluent-ffmpeg\lib\processor.js:180:22)
   at ChildProcess.emit (node:events:513:28)
   at ChildProcess._handle.onexit (node:internal/child_process:291:12)

and the saved video don't have a duration, i can't move the pin to control the time on the video.

I've tried executing the same command on a terminal and it works just fine. i've tried with many kill signal it's always the same issue.

function record(req, res) {
   if (ffmpegProcess && !ffmpegProcess.killed) {
       console.log('Recording is already in progress.');
       res.status(400).json({ success: false, error: 'Recording already in progress.' });
       return;
   }

   ffmpegProcess = ffmpeg(inputUrl)
       .outputOptions('-c:v', 'copy')
       .outputOptions('-c:a', 'copy')
       .on('start', function () {
           console.log('RUN')
       })
       .on('end', () => {
           console.log('Recording finished.');
       })
       .on('error', (err) => {
           console.error('Error:', err);
       })
       .on('stderr', function (stderrLine) {
           console.log('Stderr output: ' + stderrLine);
       }).save(outputPath);
   res.status(200).json({ success: true, message: 'Recording started.' });
}

function stopRecord(req, res) {
   if (ffmpegProcess && !ffmpegProcess.killed) {
       ffmpegProcess.kill(2);
       res.status(200).json({ success: true, message: 'Recording stopping.' });
   } else {
       console.log('No active recording process to stop.');
       res.status(400).json({ success: false, error: 'No active recording process.' });
   }
}

0

There are 0 best solutions below