MediaStreamTrackProcessor
The MediaStreamTrackProcessor interface of the Insertable Streams for MediaStreamTrack API consumes a MediaStreamTrack object's source and generates a stream of media frames.
Constructor
MediaStreamTrackProcessor()Creates a new
MediaStreamTrackProcessorobject.
Instance properties
Examples
The following example is from the article Insertable streams for MediaStreamTrack, and demonstrates a barcode scanner application, which transforms the stream accessed via MediaStreamTrackProcessor.readable by highlighting the barcode.
js
const stream = await getUserMedia({ video: true });
const videoTrack = stream.getVideoTracks()[0];
const trackProcessor = new MediaStreamTrackProcessor({ track: videoTrack });
const trackGenerator = new MediaStreamTrackGenerator({ kind: "video" });
const transformer = new TransformStream({
async transform(videoFrame, controller) {
const barcodes = await detectBarcodes(videoFrame);
const newFrame = highlightBarcodes(videoFrame, barcodes);
videoFrame.close();
controller.enqueue(newFrame);
},
});
trackProcessor.readable
.pipeThrough(transformer)
.pipeTo(trackGenerator.writable);
Specifications
| Specification |
|---|
| MediaStreamTrack Insertable Media Processing using Streams # track-processor-interface |
Browser compatibility
Report problems with this compatibility data on GitHub| desktop | mobile | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
MediaStreamTrackProcessor | |||||||||||
MediaStreamTrackProcessor() constructor | |||||||||||
readable | |||||||||||
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- In development. Supported in a pre-release version.
- In development. Supported in a pre-release version.
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.