fluent-ffmpeg / node-fluent-ffmpeg

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

NodeJS process crash when killing ffmpeg instance #861

Open Ekliptor opened 5 years ago

Ekliptor commented 5 years ago

I am using ffmpeg for screenshot generation and video transcoding on many servers. Sometimes a task doesn't finish, so I added a code to abort it using setTimeout()

let commandObj = FfmpegCommand(..);
setTimeout(() => {
     commandObj.kill("SIGKILL");
}, 10000);

This works 99% of the time, however sometimes I get crashes with stacktraces telling me that stdErr is undefined

TypeError: Cannot read property 'get' of undefined", "    
at endCB (/home/staydown/nodejs/SD_Inspector/SpiderManager/node_modules/fluent-ffmpeg/lib/processor.js:544:37)", "    
at ChildProcess.<anonymous> (/home/staydown/nodejs/SD_Inspector/SpiderManager/node_modules/fluent-ffmpeg/lib/processor.js:159:9)", "    
at ChildProcess.emit (events.js:182:13)", "    
at Process.ChildProcess._handle.onexit (internal/child_process.js:235:12)", "    
at onErrorNT (internal/child_process.js:406:16)", "    at process._tickCallback (internal/process/next_tick.js:63:19)"

Since the lines above 159 already check for process exit, I suggest adding a check if stdErr is undefined or a try-catch.

njoyard commented 5 years ago

Oh actually I think we're just missing the stdoutRing/stderrRing arguments on line 159 :confused:

ocramot commented 5 years ago

I stumpled upon the same problem today and I made a simple fix for it: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/pull/883

Birowsky commented 3 years ago

This happens in my aws lambda, no idea what causes it. If anyone could share a workaround, I'd really appreciate it.

mustafa-colakoglu commented 1 year ago

This happens in my aws lambda, no idea what causes it. If anyone could share a workaround, I'd really appreciate it.

Solved with : https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/935