| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrackProcessor | [Back] [Original] |
Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
Note: This feature is only available in Dedicated Web Workers.
Warning: Browsers differ on which global context they expose this interface in (e.g., only window in some browsers and only dedicated worker in others), making them incompatible. Keep this in mind when comparing support.
The MediaStreamTrackProcessor interface of the Insertable Streams for MediaStreamTrack API consumes a video MediaStreamTrack object's source and generates a stream of VideoFrame objects.
MediaStreamTrackProcessor()Creates a new MediaStreamTrackProcessor object.
window.MediaStreamTrackProcessor() Creates a new MediaStreamTrackProcessor object on the main thread that can process both video and audio.
MediaStreamTrackProcessor.discardedFrames A number indicating how many frames have been dropped by the processor.
MediaStreamTrackProcessor.readableReturns a ReadableStream.
MediaStreamTrackProcessor.totalFrames A number indicating how many frames have been received by the processor in total.
The following example is from the article Unbundling MediaStreamTrackProcessor and VideoTrackGenerator. It transfers a camera MediaStreamTrack to a worker for processing. The worker creates a pipeline that applies a sepia tone filter to the video frames and mirrors them. The pipeline culminates in a VideoTrackGenerator whose MediaStreamTrack is transferred back and played. The media now flows in real time through the transform off the main thread.
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
const [track] = stream.getVideoTracks();
const worker = new Worker("worker.js");
worker.postMessage({ track }, [track]);
const { data } = await new Promise((r) => {
worker.onmessage = r;
});
video.srcObject = new MediaStream([data.track]);
worker.js:
onmessage = async ({ data: { track } }) => {
const vtg = new VideoTrackGenerator();
self.postMessage({ track: vtg.track }, [vtg.track]);
const { readable } = new MediaStreamTrackProcessor({ track });
await readable
.pipeThrough(new TransformStream({ transform }))
.pipeTo(vtg.writable);
};
| Specification |
|---|
| MediaStreamTrack Insertable Media Processing using Streams # mediastreamtrackprocessor |
VideoTrackGeneratorNote:
This article was written before the API was restricted to workers and video. Beware its use of the non-standard version of MediaStreamTrackProcessor which blocks on the main thread.
This page was last modified on Aug 7, 2026 by MDN contributors.
MediaStreamTrackProcessorYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |