Use FFmpeg to decode a screen recording and write selected frames as numbered image files, then let Node.js process those files as they are produced. For example, the FFmpeg filter fps=1 extracts about one frame per second, while -ss, -t and -frames:v let you choose a time window or cap the output. This approach avoids loading the entire recording—or every extracted image—into a Node.js array.
Choose how to sample the recording
Before writing code, decide whether you need a regular sample, a single image, or a bounded segment. These are different jobs: a rate controls how often FFmpeg emits frames; a seek position and duration control the part of the video being read; and a frame limit caps how many images are written.
| Goal | FFmpeg option or filter | Example |
|---|---|---|
| One frame per second | -vf fps=1 |
Sample the recording at a one-frame-per-second rate. |
| Five frames per second | -vf fps=5 |
Write a denser regular sample. |
| One frame at a timestamp | -ss and -frames:v 1 |
Seek to a point and emit one image. |
| A time-bounded sample | -ss, -t and -vf |
Start at a chosen point, process a duration, and sample at a chosen rate. |
| A maximum frame count | -frames:v |
Stop after the specified number of output frames. |
A filter such as fps=1 describes sampling frequency; it does not mean “the first frame only.” For a one-off image, use -frames:v 1. If matching exact timestamps matters, verify the extracted images against the input’s time base: an output sequence number is not necessarily a wall-clock timestamp.
Install FFmpeg and prepare a Node.js project
Install FFmpeg using the package manager or distribution appropriate to your operating system, and make sure the ffmpeg executable is available on the process PATH. Confirm that it runs with ffmpeg -version. Node.js must also be installed. The example below uses ECMAScript modules and built-in Node.js modules, so it does not need an npm wrapper package.
#1 Best Overall
- 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
- 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
- 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
- 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
- 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
-
Create a project directory and initialize it with
npm init -y. -
Enable ES modules by adding
"type": "module"to the project’spackage.json, or save the script with an.mjsextension. -
Put the recording at
recording.mp4in the project directory, or change the input path in the script. -
Save the following code as
extract-frames.mjsand runnode extract-frames.mjs.Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Extract frames with Node.js child_process
This script creates the output directory, starts FFmpeg with an argument array, collects diagnostic output from stderr, and waits for FFmpeg to finish. It writes sequential PNG files named frame-00000.png, frame-00001.png, and so on.
import { spawn } from 'node:child_process';
import { mkdir } from 'node:fs/promises';
await mkdir('frames', { recursive: true });
const args = [
'-hide_banner',
'-loglevel', 'error',
'-i', 'recording.mp4',
'-vf', 'fps=1',
'-start_number', '0',
'frames/frame-%05d.png'
];
const ffmpeg = spawn('ffmpeg', args, {
stdio: ['ignore', 'ignore', 'pipe']
});
let diagnostics = '';
ffmpeg.stderr.setEncoding('utf8');
ffmpeg.stderr.on('data', chunk => {
diagnostics += chunk;
});
const exitCode = await new Promise((resolve, reject) => {
ffmpeg.once('error', reject);
ffmpeg.once('close', resolve);
});
if (exitCode !== 0) {
throw new Error(`ffmpeg failed (${exitCode}): ${diagnostics}`);
}
console.log('Frame extraction complete.');
The array passed to spawn keeps each option and value separate instead of building a shell command string. This avoids shell-quoting problems with paths that contain spaces and makes the effective FFmpeg arguments easy to inspect. Standard output is ignored because this command writes image files; standard error is retained for diagnostics. The close event provides the process exit code after its stdio streams have closed, while the error event catches failures to start the process, such as a missing executable.
Rank #2
- 【1080P HD High Quality】Capture resolution up to 1080p for video source and it is ideal for all HDMI devices such as PS4, PS3, Xbox One, Xbox 360, Wii U, DVDs, DSLR, Camera, Security Camera and set top box. Note: Video input supports 4K30/60Hz and 1080p120/144Hz. Does not support 4K120Hz/144Hz. Output supports up to 2K30Hz.
- 【Plug and Play】No driver or external power supply required, true PnP. Once plugged in, the device is identified automatically as a webcam. Detect input and adjust output automatically. Won't occupy CPU, optional audio capture. No freeze with correct setting.
- 【Compatible with Multiple Systems】suitable for Windows and Mac OS. High speed USB 3.0 technology and superior low latency technology makes it easier for you to transmit live streaming to Twitch, Youtube, Facebook, Twitter, OBS, Potplayer and VLC.
- 【HDMI LOOP-OUT】Based on the high-speed USB 3.0 technology, it can capture one single channel HD HDMI video signal. There is no delay when you are playing game live.
- 【Support Mic-in for Commentary】Rybozen capture card has microphone input and you can use it to add external commentary when playing a game. Please note: it only accepts 3.5mm TRS standard microphone headset.
Change the sample rate or output format
Replace 'fps', '1'—in this example, the single filter argument 'fps=1'—with 'fps=5' for five sampled frames per second. Change the filename suffix to .jpg or .webp to use another output format supported by the FFmpeg build. PNG preserves lossless pixels; JPEG and WebP may reduce storage use. Choose based on the needs of the downstream OCR, computer-vision, or archival step, and validate the image quality for that use.
Capture one frame at a timestamp
For a single representative image, use this command:
ffmpeg -ss 00:00:12.500 -i recording.mp4 -frames:v 1 frame.png
In Node.js, pass the same tokens as an argument array, for example ['-ss', '00:00:12.500', '-i', 'recording.mp4', '-frames:v', '1', 'frame.png']. Seeking before the input is useful for a fast seek; if precision at a particular point matters, check the result against the source rather than assuming every seek lands on an exact display timestamp.
Extract a bounded segment
To sample a ten-second segment beginning at two minutes, producing two frames per second, run:
ffmpeg -ss 00:02:00 -i recording.mp4 -t 00:00:10 -vf fps=2 frames/frame-%05d.webp
The seek, duration, sampling filter and output suffix can be adjusted independently. A bounded interval helps limit temporary output, but the number of actual images depends on the input and sampling behavior; do not treat the requested duration multiplied by the nominal rate as a guaranteed frame count.
Choose filenames and image formats
The image2 output muxer accepts numbered filename patterns such as img-%03d.jpeg. The number of percent signs indicates the minimum number of digits, so %05d yields five-digit sequence numbers for ordinary values. Use -start_number when you want a particular first index. Numbered files sort naturally and are straightforward to enumerate in Node.js.
Recommended Free Tools
Rank #3
- 【4K HDMI Input, 2K@30Hz Recording】Powered by a true USB 3.0 high-speed interface, the capture card supports up to 4K@30Hz HDMI input and records at 2K@30Hz or 1080P@60Hz. Perfect for gamers, streamers, and professionals who need crisp, smooth video for live streaming, gameplay recording, or online meetings.
- 【Ultra Low Latency Screen Sharing】Built with a premium aluminum alloy shell and advanced chipset for stable heat dissipation, ensuring ultra-low latency transmission. Capture high-quality video and dual-channel audio in real time—no lag, no frame drop—ideal for Twitch, YouTube, or OBS streaming.
- 【Easy Plug and Play, Compact & Portable】No driver or external power required—just plug and play via USB 3.0 or Type-C connection to your Windows or macOS computer. Lightweight and compact design makes it easy to carry for outdoor streaming, live shows, or mobile recording setups.
- 【Wide Compatibility & Multi-Device Support】Compatible with Windows 7 8 10 11, macOS, Linux,Android and supports most popular software such as OBS, Zoom, VLC, Twitch Studio, and more. Works seamlessly with PS4, PS5, Xbox, Switch, DSLR cameras, TV boxes, and other HDMI-output devices for streaming to YouTube, Twitch, etc.
- 【What You Get】Includes: HDMI Capture Card, USB 3.0 to USB-C Adapter, User Manual. Tips: Make sure your tablet’s OTG function is enabled before connecting. Test your HDMI device with a monitor first to confirm video and audio output, then connect to the Video Capture Card for recording.
For workflows that need names based on presentation timestamps or formatted times, FFmpeg also has timestamp-oriented options such as frame_pts and strftime. These are alternatives to a simple sequence counter; choose them only when timestamp-derived naming is useful to the consumer. A single output image can be limited with -frames:v 1.
Process frames without accumulating them in memory
Writing every extracted image into an array or keeping all decoded pixels in memory makes resource use grow with the recording. A simpler pattern is to process paths through a bounded queue: enumerate completed frame files, give each path to OCR or image analysis, persist its result, and then delete or archive the image. Limit the number of concurrent consumers so a slow analysis service cannot cause an unbounded backlog.
For a basic sequential workflow, run FFmpeg to completion and then process files one at a time. This is easy to reason about but waits until extraction finishes before analysis begins. To overlap extraction and analysis, watch the output directory for new files or build a producer-consumer pipeline. In either case, use a queue with a fixed capacity and pause or throttle production when consumers fall behind. Handle partial output carefully: do not open a file until it is complete, and do not treat a directory listing as a reliable ordering mechanism without sorting by the numeric sequence.
When a pipe is appropriate
For streaming, FFmpeg can emit image data through a pipe, but the consumer must know how to identify complete frame boundaries. With raw video, that means knowing the width, height, pixel format and resulting frame size before parsing the byte stream. If any of those assumptions is wrong, frame boundaries become invalid and the pixels may be misinterpreted. A file sequence is often the safer option when output size is manageable; a pipe avoids per-frame files but requires explicit framing and backpressure.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Use fluent-ffmpeg when its abstraction helps
The fluent-ffmpeg wrapper documents methods including .frames(), .save(), .pipe() and .run(), as well as lifecycle events and a screenshot helper that accepts a count, timemarks, output folder, filename tokens, size and fast-seek settings. It can make sparse thumbnail jobs more convenient, while direct spawn keeps the exact FFmpeg flags visible.
import ffmpeg from 'fluent-ffmpeg';
ffmpeg('recording.mp4')
.outputOptions(['-vf', 'fps=1'])
.on('error', err => console.error(err.message))
.on('end', () => console.log('frames complete'))
.save('frames/frame-%05d.png');
Choose one approach based on what the job needs rather than mixing abstractions without a reason:
Rank #4
- High-Quality Video Capture, 4K HDMI Capture Card Ready: Capture smooth and vibrant video with this 4K HDMI capture card, engineered for gamers and content creators who demand crisp 1080P 60FPS video quality. Whether you're streaming to Twitch or recording gameplay for YouTube, your footage will look professional and detailed
- Plug-and-Play USB Capture Card, No Drivers Needed: Designed as a USB capture card for streaming, this device works instantly out of the box, just plug into your PC or laptop and start capturing. Fully compatible with popular software like OBS Studio, Streamlabs, and XSplit, making setup quick and stress-free for beginners and pros alike
- Universal Compatibility PS5, Xbox, Switch & More: Stream or record gameplay from virtually any HDMI-enabled device including Nintendo Switch, PS5, Xbox Series X, DSLR cameras, and PCs. The video capture card for gaming supports seamless passthrough so you can play without lag while your audience watches every frame in real time
- Low-Latency Performance for Smooth Streaming: This capture card for streaming minimizes delay between gameplay and broadcast, so you get reliable, low-latency capture that works well for competitive gaming, live broadcasts, and podcast sessions. Suitable for those building their channel with high-quality, engaging content
- Compact & Portable Design for Content Creators: Lightweight and portable, this USB 3.0 capture card works well for creators who travel or switch gaming setups often. Throw it in your bag and stream or record wherever you are, at home, events, LAN parties, streaming or studio sessions
- Direct spawn: use it when exact argument ordering, stderr diagnostics, process exit status, or minimizing wrapper dependencies is important.
- Wrapper: use it when its helper methods express the job more clearly, especially for sparse timemark-based thumbnails.
- Files: use numbered output when downstream processing is easier with paths and storage use is acceptable.
- Pipe: use it when avoiding per-image files is worth implementing framing and backpressure correctly.
In production, log the generated command or argument list, pin the FFmpeg binary and version in the deployment environment, and treat an absent executable as a startup or configuration error.
Troubleshoot common failures
spawn ffmpeg ENOENT: Node.js could not find the executable. Install FFmpeg in the runtime environment or configure the executable path explicitly, then verify it from the same service account that runs Node.js.- Nonzero FFmpeg exit code: inspect the captured stderr text for an invalid input path, unsupported codec, malformed option, or unwritable output directory. Do not report success solely because some image files exist; a failed run can leave partial output.
- No images appear: check that the input contains a decodable video stream, the output directory exists and is writable, the selected time window overlaps the video, and the output pattern is valid.
- Unexpectedly sparse or dense output: verify the intended sampling semantics.
fps=1is a filter rate;-frames:v 1is a hard output-count limit. They solve different problems. - Images are too large or disk fills: lower the sampling rate, restrict the segment with
-ssand-t, or choose a more compact image format if it satisfies the analysis quality requirement. Remove processed files when they no longer need to be retained. - Memory rises during analysis: avoid collecting image buffers or results indefinitely. Bound concurrency and queue length, persist results incrementally, and apply backpressure to the producer.
- Frames do not align with expected timestamps: do not infer elapsed wall-clock time solely from the sequence index. Validate seek behavior and the source time base; use timestamp-oriented naming if the downstream workflow needs presentation-time references.
Performance, reliability and cost considerations
Extraction speed, memory use and output volume depend on the recording’s codec, resolution, hardware, sampling rate and chosen image format. There is no single throughput or memory figure that applies to all Node.js/FFmpeg jobs. Measure representative recordings in the deployment environment before setting queue sizes, concurrency, disk quotas or processing deadlines.
Reliability comes from making the process boundary observable: capture stderr, check the exit code, handle spawn errors, and distinguish complete output from partial files. For repeatable deployments, pin the FFmpeg binary/version and keep the invocation visible in logs. Storage requirements are governed chiefly by the portion of video sampled, sample rate, image dimensions and encoding choice; bound the time window or clean up files when disk use must remain predictable.
Or skip the browser setup
If what you need is a clean image of a live web page—not frames from an existing screen recording—ScreenshotNeo takes a webpage screenshot through one API request. It is not a video-frame extractor and does not replace FFmpeg for recordings.
cURL example, documented at ScreenshotNeo’s API docs:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie/consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages and failed loads are never billed. Its MCP server provides screenshot tools for AI agents, and the Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Frequently Asked Questions
Does fps=1 select exactly one frame from the entire recording?
No. It samples at a rate of one frame per second. Use -frames:v 1 when you need a one-image output limit.
Can the output filenames contain timestamps instead of sequence numbers?
Yes. FFmpeg documents timestamp-oriented options including frame_pts and strftime; use them when presentation-time-based naming is required.
Is a screenshot API suitable for extracting frames from an MP4?
No. A screenshot API captures a webpage; use FFmpeg to decode video recordings.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.




