Node-fluent-ffmpeg: How to end process without destroying file?

Created on 6 Mar 2017  路  3Comments  路  Source: fluent-ffmpeg/node-fluent-ffmpeg

When I use command (on Windows):

ffmpeg -i http://file.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4

and I want to stop I click Ctrl+C, then file saves correctly. How can I end process in the same way in node?

    var command = ffmpeg('http://file.m3u8')
    .save('output.mp4').outputOptions([
      '-c copy',
      '-bsf:a aac_adtstoasc'
    ]);

I've tried this: command.kill('SIGINT'); and this: command.kill('SIGKILL); but those commands destroy output file. I'm not sure ".save()" is the correct function to save output in this case.

Most helpful comment

so after doing some digging I was able to get the results I was looking for by creating a method as such:

const stop = (movie) => {
  return movie.ffmpegProc.stdin.write('q');
}

const video = ffmpeg('...').save('...');

setTimeout(() => {
  // safely end the ffmpeg process without destroying the file.
  stop(video);
}, 30000);

All 3 comments

so after doing some digging I was able to get the results I was looking for by creating a method as such:

const stop = (movie) => {
  return movie.ffmpegProc.stdin.write('q');
}

const video = ffmpeg('...').save('...');

setTimeout(() => {
  // safely end the ffmpeg process without destroying the file.
  stop(video);
}, 30000);

@joseym it works great, thanks a lot

sometime. write('q') ,it seem does not work,have you ever meeting ?becouse it no response at ffmpeg process for long time

Was this page helpful?
0 / 5 - 0 ratings