Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. CropTarget

CropTarget

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

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

TheCropTarget interface of theScreen Capture API provides a static method,fromElement(), which returns aCropTarget instance that can be used to crop a captured video track to the area in which a specified element is rendered.

Static methods

fromElement()Experimental

Returns aCropTarget instance that can be used to crop a captured video track to the area in which a specified element is rendered.

Examples

js
// Options for getDisplayMedia()const displayMediaOptions = {  preferCurrentTab: true,};// Create crop target from DOM elementconst demoElem = document.querySelector("#demo");const cropTarget = await CropTarget.fromElement(demoElem);// Capture video stream from user's webcam and isolate video trackconst stream =  await navigator.mediaDevices.getDisplayMedia(displayMediaOptions);const [track] = stream.getVideoTracks();// Crop video trackawait track.cropTo(cropTarget);// Broadcast cropped stream in <video> elementvideoElem.srcObject = stream;

SeeUsing the Element Capture and Region Capture APIs for in-context example code.

Specifications

Specification
Region Capture
# crop-target

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp