← Chrome 150 reference

v150 · media · webcodecs · streams

MediaStreamTrackProcessor frame counters

Chrome 150 adds discardedFrames and totalFrames read-only attributes to MediaStreamTrackProcessor, letting developers monitor how many frames have arrived and how many were dropped when the processor's ReadableStream was not being consumed fast enough.

at a glance

Shipped inChrome 150 (Enabled by default)
StatusEnabled by default
SpecMedia Capture Transform — MediaStreamTrackProcessor
Standards position (Firefox)Positive
Standards position (Safari)Positive
ChromeStatus6267249280286720 — MediaStreamTrackProcessor frame counters
Source: chromestatus.com/feature/6267249280286720

why it exists

MediaStreamTrackProcessor exposes a MediaStreamTrack (camera, screen capture, audio) as a ReadableStream of VideoFrame or AudioData objects. If the consuming code (e.g. a WebCodecs encoder or a canvas-drawing loop) cannot keep up with the incoming frame rate, the processor silently drops frames rather than buffering indefinitely.

Before Chrome 150 there was no way to tell how many frames had been dropped. Developers building WebRTC pipelines, video effects, or recording applications had no visibility into whether their processing was keeping up. The new discardedFrames and totalFrames counters surface this information directly on the processor, making it possible to detect back-pressure problems and measure pipeline health.

Source: chromestatus feature summary

shape of the API

PropertyTypeDescription
MediaStreamTrackProcessor.totalFramesnumberTotal number of frames received from the track since the processor was created
MediaStreamTrackProcessor.discardedFramesnumberNumber of frames dropped because the readable stream was not being read fast enough

Both properties are read-only and increase monotonically. The drop rate can be computed as discardedFrames / totalFrames.

Source: Media Capture Transform spec

example

const stream = await navigator.mediaDevices.getUserMedia({ video: true });
const [track] = stream.getVideoTracks();
const processor = new MediaStreamTrackProcessor({ track });
const reader = processor.readable.getReader();

let frameCount = 0;

async function processFrames() {
  while (true) {
    const { value: frame, done } = await reader.read();
    if (done) break;

    // Do something with the frame (e.g. encode, draw to canvas)
    frame.close();
    frameCount++;

    // Chrome 150+: monitor pipeline health
    if (frameCount % 60 === 0) {
      const total = processor.totalFrames;
      const dropped = processor.discardedFrames;
      const dropRate = total > 0 ? (dropped / total * 100).toFixed(1) : 0;
      console.log(`Frames: ${total} total, ${dropped} dropped (${dropRate}%)`);
      if (dropped / total > 0.1) {
        console.warn('High frame drop rate — processing pipeline too slow');
      }
    }
  }
}

processFrames();
Source: Media Capture Transform spec

browser support

BrowserSupportNotes
Chrome 150+Enabled by defaultAll platforms
FirefoxPositiveNot yet shipped
SafariPositiveNot yet shipped
Source: chromestatus.com/feature/6267249280286720

see also