Reputation: 45
I am interested in using ffmpeg with node. I have looked at the many libraries available (such as fluent-ffmpeg), but they are not what I'm looking for.
I would like to know if there is a way to execute FFMPEG with node, but instead of creating a file, transfering everything to a stream. I don't want to use disc space for 'reasons' and it would make more sense for my application to execute a command and pipe that audio/video into a node stream instead.
Is there a way to do this? If so, what's my best bet?
Upvotes: 3
Views: 3903
Reputation: 163603
Yes, this is really easy as a child process.
If you use a hyphen -
for an input or output filename, it will allow you to pipe with STDIN or STDOUT. Therefore, you just need to do something like this:
const ffmpeg = child_process.spawn('ffmpeg', [
'-i', '-',
// Some other parameters here
'-'
]);
You can use ffmpeg.stdin
and ffmpeg.stdout
here.
See also: https://nodejs.org/api/child_process.html
Upvotes: 3