Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To save the current frame of an HTML5 <video> as a JPG, wait until the video has metadata, seek and pause at the required time, draw the video onto a canvas, then export that canvas with toBlob('image/jpeg'). The browser can download the resulting Blob immediately. For local or server-side batch work, FFmpeg is usually the better choice.

Browser method: capture a frame from an HTML video

This method runs entirely in the browser. It works for videos that the page is allowed to read, including same-origin media and cross-origin media served with the right CORS headers.

Complete working example

<video id="video" controls crossorigin="anonymous" src="video.mp4"></video>
<label>
  Time (seconds)
  <input id="time" type="number" min="0" step="0.01" value="0">
</label>
<button id="save" type="button">Save JPG</button>

<script>
const video = document.querySelector('#video');
const timeInput = document.querySelector('#time');
const saveButton = document.querySelector('#save');
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');

function waitForEvent(target, eventName) {
  return new Promise((resolve, reject) => {
    const onEvent = () => {
      cleanup();
      resolve();
    };
    const onError = () => {
      cleanup();
      reject(target.error || new Error(`Video event failed: ${eventName}`));
    };
    const cleanup = () => {
      target.removeEventListener(eventName, onEvent);
      target.removeEventListener('error', onError);
    };
    target.addEventListener(eventName, onEvent, {once: true});
    target.addEventListener('error', onError, {once: true});
  });
}

async function seekVideo(seconds) {
  if (video.readyState < 1) {
    await waitForEvent(video, 'loadedmetadata');
  }
  const target = Math.max(0, Math.min(seconds, video.duration || seconds));
  if (Math.abs(video.currentTime - target) > 0.001) {
    video.currentTime = target;
    await waitForEvent(video, 'seeked');
  }
  if (video.readyState < 2) {
    await waitForEvent(video, 'canplay');
  }
  if ('requestVideoFrameCallback' in video) {
    await new Promise(resolve => video.requestVideoFrameCallback(() => resolve()));
  }
}

saveButton.addEventListener('click', async () => {
  saveButton.disabled = true;
  try {
    await seekVideo(Number(timeInput.value) || 0);
    if (!video.videoWidth || !video.videoHeight) {
      throw new Error('Video dimensions are not available yet.');
    }
    canvas.width = video.videoWidth;
    canvas.height = video.videoHeight;
    ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
    canvas.toBlob(blob => {
      if (!blob) throw new Error('The browser could not encode a JPG.');
      const url = URL.createObjectURL(blob);
      const link = Object.assign(document.createElement('a'), {
        href: url,
        download: 'frame.jpg'
      });
      link.click();
      setTimeout(() => URL.revokeObjectURL(url), 1000);
    }, 'image/jpeg', 0.9);
  } catch (error) {
    console.error(error);
    alert(error.message || 'Could not capture the frame.');
  } finally {
    saveButton.disabled = false;
  }
});
</script>

Replace video.mp4 with the media URL. The canvas is sized to the source video’s intrinsic dimensions, so a CSS-scaled preview does not reduce the captured resolution. The 0.9 argument is JPEG quality, from 0 to 1; higher values generally create larger files.

Why each readiness step matters

  • loadedmetadata: supplies duration and intrinsic videoWidth/videoHeight. Before it fires, those dimensions can be zero.
  • currentTime and seeked: seeking is asynchronous. Drawing immediately after assigning currentTime can capture the previous frame.
  • canplay: confirms that usable media data is available.
  • requestVideoFrameCallback(): where supported, waits for a decoded frame that is ready to be presented before drawImage().

Capture the displayed size or a custom size

For native resolution, use video.videoWidth and video.videoHeight. To create a smaller JPG, set a deliberate output width and calculate height from the source aspect ratio:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Guermok Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P 60FPS & 2K 30FPS
  • 【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
const outputWidth = 1280;
canvas.width = outputWidth;
canvas.height = Math.round(outputWidth * video.videoHeight / video.videoWidth);
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);

Do not use video.clientWidth or offsetWidth unless you intentionally want a screen-sized image; those values describe layout pixels, not the media’s encoded resolution.

toBlob() versus toDataURL()

Method Best for Trade-off
toBlob() Downloads, uploads and larger frames Asynchronous, but avoids keeping a large base64 string in memory
toDataURL('image/jpeg', quality) Small images or an immediate data URL Stores the complete encoded image in a JavaScript string

If JPEG encoding is unavailable, a browser may return another format. When the MIME type matters, inspect blob.type (or the prefix of the data URL) before naming the file.

CORS and the tainted-canvas error

A video fetched from another origin must be CORS-enabled before it is drawn. Keep crossorigin="anonymous" on the video and ensure the video server returns a compatible Access-Control-Allow-Origin response. The attribute must be present before the browser starts loading the source.

<video id="video" crossorigin="anonymous" src="https://media.example/video.mp4"></video>

If the server does not grant permission, the browser marks the canvas as tainted. The drawing itself may appear to work, but canvas.toBlob() and canvas.toDataURL() throw a SecurityError. Page JavaScript cannot bypass this policy. If you control the media server, configure its CORS response; otherwise proxy the file through a server you control, subject to licensing and access rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Extract frames with FFmpeg

FFmpeg is preferable when the input is a local file, you need repeatable timestamps, or you want many frames without opening a browser.

Rank #2
Sale
Capture Card, 4K HDMI Video Capture Card, Game Capture Card, 1080P 60FPS Video Capture Device, HDMI to USB 3.0 Capture Card for Streaming, Work with Camera/Xbox/PS4/PS5/PC/OBS
  • 【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.

One frame at a timestamp

ffmpeg -ss 00:00:10 -i input.mp4 -frames:v 1 frame.jpg

-ss selects the seek position, and -frames:v 1 caps output at one image. Placing -ss before -i is fast, but can seek to a nearby keyframe. For more accurate, slower seeking, put it after the input:

ffmpeg -i input.mp4 -ss 00:00:10 -frames:v 1 frame.jpg

One JPG per second

ffmpeg -i input.mp4 -r 1 -f image2 'frame-%03d.jpeg'

The explicit pattern creates names such as frame-001.jpeg. Change -r 1 to the desired extraction rate. Add a scaling filter when you need controlled dimensions:

ffmpeg -ss 00:00:10 -i input.mp4 -frames:v 1 -vf "scale=1280:-2" frame.jpg

FFmpeg reads files and network inputs directly, so it is not subject to browser canvas CORS. It writes files rather than triggering a browser download and is suited to batch jobs, while canvas is convenient for an interactive viewer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Browser canvas or FFmpeg?

Need Choose canvas Choose FFmpeg
Execution In the visitor’s browser Local machine or server
Input access Requires CORS for another origin Filesystem and permitted network access
Timing Interactive seeking from a player Scripted timestamps and frame rates
Output Blob, download or upload Image files and sequences
Scale Single or occasional frames Many videos or recurring extraction jobs

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. It captures a rendered page, not an arbitrary decoded frame from a protected video file, so use the browser or FFmpeg method above when you need a precise video timestamp. It is useful when the frame is part of a public webpage and you want an automated page image without maintaining a browser.

One GET request returns PNG, JPEG, WebP or PDF. The API accepts the page URL and can wait for a selector, delay or network idle, click an element, apply custom JavaScript or CSS, choose a device and viewport, and capture a selected element. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing result.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
const buffer = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', buffer));

See the full parameter list and response behavior in the ScreenshotNeo documentation. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Plans include 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Rank #3
Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P60FPS HDMI Capture Card for Streaming, Gaming, Video Recording Compatible with Switch, Xbox, PS4/5, OBS,iPad Mac OS Windows,Camera, Zoom(Silver)
  • 【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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The saved image is blank or data:,

Metadata or frame data was not ready, or the canvas has zero dimensions. Wait for loadedmetadata and a usable state such as canplay, then verify that video.videoWidth and video.videoHeight are non-zero.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The JPG shows the previous frame

Wait for the seeked event and, where available, requestVideoFrameCallback() before drawing. Do not rely on a fixed short timeout.

SecurityError: The canvas has been tainted

The video is cross-origin without a permitted CORS response. Configure Access-Control-Allow-Origin on the media server and set crossorigin before src, or process the file outside the browser with FFmpeg.

The downloaded file is large

Lower the JPEG quality, reduce canvas dimensions, or use a format appropriate to your workflow. Remember that quality is a 0–1 value and larger dimensions multiply the encoded data.

Seeking never reaches the requested time

Clamp the target to the known duration, wait for metadata, and handle media errors. Highly compressed videos may seek to the nearest decodable position; FFmpeg with post-input -ss provides a more accurate server-side alternative.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Capture Card 4K HDMI Video Streaming to USB 3.0 1080P 60FPS Capture Device
  • 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

The browser cannot play the source

Check the media codec, URL, authentication and server range-request behavior. A frame cannot be drawn until the browser can decode the video; use FFmpeg when the browser lacks the required codec.

Practical quality and reliability checklist

  • Wait for metadata before reading dimensions.
  • Use intrinsic dimensions unless a smaller output is intentional.
  • Await seeked and a decoded frame before drawing.
  • Use toBlob() for normal downloads and uploads.
  • Check the returned MIME type if strict JPG output is required.
  • Revoke object URLs after the download has started.
  • Expect CORS failures for media you do not control.
  • Use FFmpeg for batch extraction, exact command-line workflows and server-side processing.

Frequently Asked Questions

Can I capture a frame without displaying video controls?

Yes. Controls affect the player UI, not the pixels supplied to drawImage(); omit the controls attribute or hide the element with CSS.

Does extracting a frame change the original video?

No. Canvas creates a separate raster image; the source video file is unchanged.

Can I save a frame as PNG instead?

Yes. Pass image/png to toBlob() or toDataURL(); PNG ignores the JPEG quality argument and is usually larger for photographic frames.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.