As stated in the title, I would like to capture the screen 60 times a second and run it through a nodejs function.
Most libraries on npm
only save to disk.
I tried taking screenshots with robotjs
but only achieved 11fps.
I tried starting an RTMP server and using OBS but its delayed.
What in the world do I do?
Head over to the Video Settings > Frame Rate and select the desired framerate. (Note: The 90 or 120Hz screen recording option will only appear if your smartphone supports these frame rates.) After making changes, tap the video icon on the home screen of the app. Happy recording!
A screen recording, sometimes called a screencast or video screen capture, is a digital recording of rendered scenes (ideally 60 frames per second) on a computer screen, often containing audio narration as well as a webcam or facecam video of the narrator.
goto("https://nytimes.com"); await page. screenshot({ path: "nyt-puppeteer. png" }); await browser. close(); });
If the performance of your computer is a little poor, you are able to adjust the appropriate frame rate in the Settings tab, where you are allowed to set the frame rate from 1 to 60 flexibly. Besides, this screen capture lets you capture your screen and save it in different quality, including Standard, High, and original options.
Speaking generally, the higher the FPS is, and the smoother your videos look. If you are a gamer and want to capture your brilliant game clips with high quality for YouTube or other sites, you'd better find a high FPS screen recorder.
On the other hand, mss runs much faster than any other screen capture APIs. I used mss to apply object detection ( YOLOv2, darkflow ), and it run at over 40 frames per second. If it is used without any object detection, it should run at more fps.
On the other hand, mss runs much faster than any other screen capture APIs. I used mss to apply object detection ( YOLOv2, darkflow ), and it run at over 40 frames per second.
You can use ffmpeg
to achieve 60fps. Take a look at ffmpeg docs for more details.
const ffmpeg = require("ffmpeg-static").path;
const { spawn } = require("child_process");
const process = spawn(
ffmpeg,
["-probesize", "10M", "-f", "gdigrab", "-framerate", "60", "-i", "desktop", "-f", "flv", "-"],
{ stdio: "pipe" }
);
const stream = process.stdout;
Here you have the stream of video. Do the processing.
For example, you can write the stream to a Writable stream
const { createWriteStream } = require("fs");
const file = createWriteStream("capture.flv");
stream.pipe(file);
Or you can subscribe to chunks of data and do some processing
stream.on("data", chunk => {
console.log(chunk);
});
More about Node.JS streams
This example would only work for Windows users. Mac and Linux users should change ffmpeg
options used to spawn the process as described in the ffmpeg
docs.
Your best bet might be to create a native process for doing the capture, using platform-specific APIs, then wrap them in NAN (Native Abstraction for Node: https://github.com/nodejs/nan). There's a little learning curve, but not too bad. I've built systems for decoding JPEGs, manipulating them, and encoding in h.264 this way.
Because you're in control of the capture at the native level, you can create whatever interface you like to bring screen grabs into Node. For example, you might want to avoid marshaling images across the native-javascript interface and instead maintain handles to them, and only pull an image when you need to.
Then you can turn it all into a cool npm module and be adored by everyone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With