e01.org

MediaStreamTrackProcessor: totalFrames property

Insertable Streams for MediaStreamTrack API

Insertable Streams for MediaStreamTrack API

The **`totalFrames`** property of the MediaStreamTrackProcessor interface returns a number indicating how many frames have been received by the processor in total.

## Value

A number.

## Examples

### Basic usage

```js
async function init() {
try {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
const [track] = stream.getVideoTracks();

const processor = new MediaStreamTrackProcessor({
track,
maxBufferSize: 1,
});
const reader = processor.readable.getReader();

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

// Do something with frame...
frame.close();

console.log(
`total: ${processor.totalFrames}, discarded: ${processor.discardedFrames}`,
);
}
} catch (e) {
console.error(e.name, e.message);
}
}

document.querySelector("button").addEventListener("click", init);
```

## Specifications

## Browser compatibility

## See also

- MediaStreamTrackProcessor.discardedFrames

source: MDN Web Docs mirror · page

Cite this

"MediaStreamTrackProcessor: totalFrames property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrackProcessor/totalFrames

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy