メディアキャプチャとストリーム API (メディアストリーム)

メディアキャプチャとストリーム API (Media Capture and Streams API) は、一般的に メディアストリーム API (Media Stream API または MediaStream API) と呼ばれ、音声や映像のデータのストリーミングへの対応を提供する WebRTC に関連した API です。

これは、ストリームとその構成トラックを操作するためのインターフェイスとメソッド、データ形式に関連する制約、データを非同期に使用する際の成功とエラーのコールバック、および処理中に発行されるイベントを提供するものです。

基本概念

この API は、音声または映像に関連づけられたデータの流れを表現するための MediaStream オブジェクトの操作を基本としています。例としてメディアストリームの取得をご覧ください。

MediaStream は 0 個以上の MediaStreamTrack によって構成されます。これは様々な音声や映像のトラックを表現します。それぞれの MediaStreamTrack は、1 つ以上のチャンネルを持ちます。このチャンネルはメディアストリームの最小の単位を表現します。例えば、ステレオの音声トラックののチャンネルのそれぞれのように、与えられたスピーカーに関連づけられた音声信号です。

MediaStream オブジェクトは、1 つの入力と 1 つの出力を持ちます。 MediaStream オブジェクトは、ローカルで呼び出される getUserMedia() によって生成され、ユーザーのカメラやマイクの 1 つを入力ソースとして持ちます。ローカルでない MediaStream は、 <video><audio> などのメディア要素や、WebRTC RTCPeerConnection API によって取得できるネットワーク越しに生成されたストリーム、ウェブオーディオ APIMediaStreamAudioDestinationNode によって作成されたストリームとして表現されます。

MediaStream オブジェクトの出力はコンシューマー (consumer) に接続されます。出力として <audio><video> などのメディア要素、 WebRTC RTCPeerConnection API、ウェブオーディオ APIMediaStreamAudioSourceNodeが使用できます。

インターフェイス

これらのリファレンス記事では、メディアキャプチャとストリーム API を構成する各インターフェイスについて知っておく必要がある基本的な情報を見つけられます。

イベント

ガイドとチュートリアル

能力と制約と設定の記事では、制約能力、メディア設定の概念について説明しています。また、制約エクササイザ―を記載しており、コンピューターの A/V 入力機器(ウェブカメラやマイクなど)からの音声と映像のトラックに対して異なる制約集合を適用した結果を試してみることができます。

getUserMedia() による写真の撮影 の記事では、getUserMedia() を使用して、 getUserMedia() に対応しているコンピューターや携帯電話のカメラにアクセスし、それで写真を撮る方法を示しています。

ブラウザーの互換性

api.MediaStream

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
MediaStream
MediaStream() constructor
active
active event
Non-standard
addTrack
addtrack event
clone
getAudioTracks
getTrackById
getTracks
getVideoTracks
id
inactive event
Non-standard
removeTrack
removetrack event

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Non-standard. Check cross-browser support before using.
See implementation notes.
Requires a vendor prefix or different name for use.
Has more compatibility info.

api.MediaStreamTrack

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
MediaStreamTrack
applyConstraints
aspectRatio constraint
autoGainControl constraint
channelCount constraint
deviceId constraint
displaySurface constraint
echoCancellation constraint
facingMode constraint
frameRate constraint
groupId constraint
height constraint
latency constraint
logicalSurface constraint
noiseSuppression constraint
resizeMode constraint
sampleRate constraint
sampleSize constraint
suppressLocalAudioPlayback constraint
Experimental
volume constraint
DeprecatedNon-standard
width constraint
capturehandlechange event
Experimental
clone
contentHint
enabled
ended event
getCapabilities
getCaptureHandle
Experimental
getConstraints
getSettings
id
kind
label
mute event
muted
readyState
stop
unmute event

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.
Requires a vendor prefix or different name for use.
Has more compatibility info.

api.MediaDevices

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
MediaDevices
devicechange event
enumerateDevices
getDisplayMedia()
Audio capture support
controller option
Experimental
monitorTypeSurfaces option
Experimental
preferCurrentTab option
ExperimentalNon-standard
selfBrowserSurface option
Experimental
surfaceSwitching option
Experimental
systemAudio option
Experimental
getSupportedConstraints
getUserMedia
Secure context required
selectAudioOutput
Experimental
setCaptureHandleConfig
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
See implementation notes.
Has more compatibility info.

api.MediaDeviceInfo

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
MediaDeviceInfo
deviceId
groupId
kind
label
toJSON()

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

api.InputDeviceInfo

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
InputDeviceInfo
getCapabilities

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

api.CanvasCaptureMediaStreamTrack

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CanvasCaptureMediaStreamTrack
canvas
requestFrame

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

関連情報