RTCRtpScriptTransformer: sendKeyFrameRequest() method

Baseline 2025
Newly available

Since October 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The sendKeyFrameRequest() method of the RTCRtpScriptTransformer interface may be called by a WebRTC Encoded Transform that is processing incoming encoded video frames, in order to request a key frame from the sender.

The method may only be called when receiving video (not audio) frames and if, for whatever reason, a recipient will not be able to decode the video without a new key frame. Note that the user agent can decide that the request for a key frame is not necessary, in which case the returned promise will fulfill even though the request was not actually sent.

Note: It might be called, for example, if a new user joins a WebRTC conference, in order to reduce the time before they receive a key frame and can hence start displaying video. For more information see Triggering a key frame in Using WebRTC Encoded Transforms.

Syntax

js
sendKeyFrameRequest()

Parameters

None.

Return value

A Promise that fulfills with undefined once the request is sent, or the user agent decides that it does not need to.

Exceptions

InvalidStateError

The de-packetizer is not processing video packets, or is undefined.

Examples

The example below shows how the main thread of a WebRTC application that is receiving encoded video might pass a decryption key to a receiver transform, and request the sender emit a key frame.

Note that the main thread doesn't have direct access to the RTCRtpScriptTransformer object, so it needs to pass the key to the worker. Here we do that with a MessageChannel, transferring the second port to the transformer code running in the worker. The code assumes there is already a peer connection, and videoReceiver is an RTCRtpReceiver.

js
const worker = new Worker("worker.js");
const channel = new MessageChannel();

videoReceiver.transform = new RTCRtpScriptTransform(
  worker,
  { name: "receiverTransform", port: channel.port2 },
  [channel.port2],
);

// Post new key to the receiver
channel.port1.start();
channel.port1.postMessage({
  key: "93ae0927a4f8e527f1gce6d10bc6ab6c",
});

The rtctransform event handler in the worker gets the port as event.transformer.options.port. The code snippet below shows how that is used to listen for message events on the channel. If an event is received the handler gets the key, and then calls sendKeyFrameRequest() on the transformer.

js
event.transformer.options.port.onmessage = (event) => {
  const { key } = event.data;
  // key is used by the transformer to decrypt frames (not shown)

  // Request sender to emit a key frame.
  // Here 'rcEvent' is the rtctransform event.
  rcEvent.transformer.sendKeyFrameRequest();
};

Specifications

Specification
WebRTC Encoded Transform
# dom-rtcrtpscripttransformer-sendkeyframerequest

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
sendKeyFrameRequest
Chrome – Full support
Chrome 141 (Release date: 2025-09-30)
footnote Full support
Edge – Full support
Edge 141 (Release date: 2025-10-03)
footnote Full support
Firefox – Full support
Firefox 117 (Release date: 2023-08-29)
footnote Full support
Opera – Full support
Opera 125 (Release date: 2025-12-04)
footnote Full support
Safari – Full support
Safari 15.4 (Release date: 2022-03-14)
footnote Full support
Chrome Android – Full support
Chrome Android 141 (Release date: 2025-09-30)
footnote Full support
Firefox for Android – Full support
Firefox for Android 117 (Release date: 2023-08-29)
footnote Full support
Opera Android – Full support
Opera Android 93 (Release date: 2025-11-25)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15.4 (Release date: 2022-03-14)
footnote Full support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – Full support
WebView Android 141 (Release date: 2025-09-30)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15.4 (Release date: 2022-03-14)
footnote Full support

Legend

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

Full support
Full support
No support
No support

See also