'How to convert m3u8 file to mp4 video using nodeJS with a remote S3 input

The objective is to convert .m3u8 file(hls stream) to .mp4 video inside my NodeJS application. I've tried doing the same using ffmpeg on console and that works fine but unable to find a recently maintained package that helps me do this in node. Also, my input file is not the usual file located in my local directory but a remote AWS S3 object URL which is otherwise accessible to all(public bucket), in simpler words,

How do I do ffmpeg -i https://mycloudfrontURL/myHLSfile.m3u8 output.mp4 in JS?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source