Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. MediaStreamTrackGenerator

MediaStreamTrackGenerator

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

Note:Consider usingVideoTrackGenerator instead.

TheMediaStreamTrackGenerator interface of theInsertable Streams for MediaStreamTrack API creates aWritableStream that acts as aMediaStreamTrack source.The object consumes a stream of media frames as input, which can be audio or video frames.

Constructor

MediaStreamTrackGenerator()ExperimentalNon-standard

Creates a newMediaStreamTrackGenerator object which accepts eitherVideoFrame orAudioData objects.

Instance properties

This interface also inherits properties fromMediaStreamTrack.

MediaStreamTrackGenerator.writableExperimentalNon-standard

AWritableStream.

Instance methods

This interface doesn't implement any specific methods, but inherits methods fromMediaStreamTrack.

Examples

The following example is from the articleInsertable streams for MediaStreamTrack, and demonstrates a barcode scanner application, which process barcodes and highlights them before writing the transformed frames to the writable stream ofMediaStreamTrackGenerator.writable.

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);

See also

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp