VionetoVioneto
Back to the magazine

VIONETO MAGAZINE Playback & technology

Measure video startup time from click to first frame

Measure click-to-first-frame time in a native HTML video player. Keep metadata, frames already prepared by preloading, and playback failures separate.

A play control leads to a timeline with two points. The second point sits below the first video frame.
Measure from the play click to the browser submitting the first video frame for composition.Image: Vioneto · original illustration

A product page keeps showing the poster for a moment after someone clicks Play. If you want to compare two player configurations, define the same start and end points for both. With a native HTML video element you control, you can start at the click and stop when the browser submits the first video frame for composition.

Start with a fresh video element

For this version of the test, start with a video element that has no source and a separate Play button. In its click handler, record performance.now(), register requestVideoFrameCallback, and then set the source. Subtract the recorded start time from presentationTime to get milliseconds. For a fresh element, check that presentedFrames is 1.

const t0 = performance.now() video.requestVideoFrameCallback((now, frame) => { console.log(frame.presentationTime - t0, frame.presentedFrames) }) video.src = "demo.mp4" video.play().catch(error => console.error(error))

The presentationTime property records when the browser submitted the frame for composition. The callback can run later. This browser-side timestamp gives you a repeatable reference point for the test. A physical measurement of display output needs its own setup. Log failed and abandoned starts alongside successful measurements.

Track metadata and preloaded frames separately

In a local Chrome test with a fresh source, the click came first, then loadedmetadata, then a callback with presentedFrames equal to 1. In a second run with the source set before the click, metadata arrived first and the callback observed after the click reported frame 2. That is a reason to document preloading as a separate test condition. The metadata event is a useful diagnostic checkpoint, including when you need to know whether the browser has found the video dimensions.

Keep the comparison fair

  • Use a visible tab and a defined network condition. Record the file version, browser, cache state and preload setting.
  • Repeat each case. Group fresh-page starts separately from starts with preloaded media. Time stalls after playback starts as a separate measure.
  • For a hosted player in a cross-origin iframe, use the events exposed by its documented interface. Record which playback milestone the event represents before comparing it with measurements from another player.

When delaying a video load helps the page

Topics

Sources and further reading

  1. https://wicg.github.io/video-rvfc/
  2. https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement/requestVideoFrameCallback
  3. https://html.spec.whatwg.org/multipage/media.html#event-media-loadedmetadata