Reputation: 5542
The following code hangs indefinitely:
const pathToFfmpeg = require('ffmpeg-static');
const { promisify } = require('util');
const exec = promisify(require('child_process').exec)
(async function() {
console.log("Starting.");
let outputLogs = await exec(`${pathToFfmpeg} -i input.mp4 output.gif`);
console.log("Finished:", outputLogs);
})();
It worked the first time, but then silently hangs forever.
Upvotes: 0
Views: 406
Reputation: 5542
It's because ffmpeg
is waiting for user input on whether to overwrite output.gif, which already exists. Pass the -y
flag (which answers "yes" to the overwrite question automatically/non-interactively) like so:
await exec(`${pathToFfmpeg} -y -i input.mp4 output.gif`);
(Creating this Q&A to hopefully prevent others like me from having to spend half an hour debugging this.)
Upvotes: 1