tungs / timecut

Node.js program to record smooth movies of web pages with JavaScript animations
BSD 3-Clause "New" or "Revised" License
623 stars 72 forks source link

Pipe FFmpeg output to a function #12

Closed videowala closed 3 years ago

videowala commented 5 years ago

Sometimes it is required to save the output directly to cloud storage or stream the output as the response. I have added a config function pipeOutputTo which will be called from convertProcess.stdout.pipe(config.pipeOutputTo);

If the option is passed the output option will be ignored and the file will not be saved to the disk. Here is an example of storing the output directly to the S3 bucket.

vincaslt commented 4 years ago

Any idea if this could be merged at some point?

tungs commented 4 years ago

I like the idea behind the feature, but I have some minor implementation and style concerns. I'll try to review the code and make some suggestions this week. How necessary is it to use -movflags frag_keyframe+empty_moov+faststart when piping? I'd rather they be optional, configurable arguments.

vincaslt commented 4 years ago

There's a relevant discussion in https://github.com/fluent-ffmpeg/node-fluent-ffmpeg/issues/346 regarding -movflags frag_keyframe+empty_moov+faststart

videowala commented 4 years ago

It's been a while since I implemented this, but I guess those flags are required to stream the output. Please note that these videos will not work on Twitter.

tungs commented 3 years ago

Much apologies for the very late response on this-- it dropped off my radar. Since it is so late, I made the changes I was going to recommend. In summary, I renamed config.pipeOutputTo to config.outputStream, and added config.outputStreamOptions, which allows specifying the output stream format and MOV muxer options, though by default it uses 'mp4' and 'frag_keyframe+empty_moov+faststart'. I also removed some of the console.logs since it can cause some problems in some scenarios.

The changes will be in the soon-to-be released version 0.2.0.