I am trying to use fluent-ffmpeg
node package with createReadStream
and createWriteStream
.
However, if I replace this line:
.output(fs.createWriteStream('assets/transcode-video.mp4'), {end: true})
I write this
.output('assets/transcode-video.mp4', {end: true})
it works. But I literally followed the documentation. I appreciate any help or hint.
const fs = require('fs');
const ffmpeg = require("fluent-ffmpeg");
const logger = console;
const options = {
timeout: 60, // seconds
logger
};
ffmpeg(fs.createReadStream('assets/video.webm'), options)
.output(fs.createWriteStream('assets/transcode-video.mp4'), {end: true})
.on('end', () => console.log('Finished processing'))
.run();
Error:
> node src/index.js events.js:292 throw er; // Unhandled 'error' event ^ Error: ffmpeg exited with code 1: pipe:1: Invalid argument
In the
.output(fs.createWriteStream('assets/transcode-video.mp4'), {end: true})
removefs.write()
, as it is unnecessary, ffmpeg will create the output file without the need you do it manually.Your code will look like this: