How to pass a video file as input to a child process in NodeJS and receive frames/images as output?

I have written a code in OpenCV C++ which takes a video and a timestamp (in HH:MM:SS format) as input, from the command line, and detects faces in that frame. The detected faces are cropped and written as PNG files.

$ ./executable video.mp4 00:00:01

Now I want to build a web API for the

executable

in NodeJS. I have used

child_process.spawn

along with the command line arguments. The application runs without any error but I'm not getting the cropped images as output. It seems my app is either not able to pass the input video to the

executable

or not able to read the output from it. This is my first NodeJS application. Here's my code.

/**
* app.js
* make sure to install express (npm install express)
* and place the executable beside this file
* or set executablePath to the correct path.
* run the app and open 'http://0.0.0.0:3000' in your browser.
*/