Encoded frames

Encoded video and audio frames an webrtc.RTCRtpScriptTransformer reads and writes, with their metadata.

class webrtc.models.rtc_encoded_frame.RTCEncodedFrameMetadata(synchronization_source=None, payload_type=None, contributing_sources=None, rtp_timestamp=None, receive_time=None, capture_time=None, sender_capture_time_offset=None, mime_type=None)

The metadata shared by encoded video and audio frames. A member the frame lacks is None.

Parameters:
  • synchronization_source (int, optional) – The SSRC of the RTP stream the frame belongs to.

  • payload_type (int, optional) – The RTP payload type of the frame.

  • contributing_sources (list of int, optional) – The CSRCs of the frame.

  • rtp_timestamp (int, optional) – The RTP timestamp of the frame.

  • receive_time (float, optional) – For a received frame, when its first packet arrived, in milliseconds since the Unix epoch.

  • capture_time (float, optional) – When the frame was captured, in milliseconds since the Unix epoch. A received frame uses the clock of the remote peer.

  • sender_capture_time_offset (float, optional) – For a received frame, the offset between the clock of the capturing system and that of the sender, in milliseconds.

  • mime_type (str, optional) – The codec of the frame, such as 'video/VP8'.

class webrtc.models.rtc_encoded_frame.RTCEncodedVideoFrameMetadata(synchronization_source=None, payload_type=None, contributing_sources=None, rtp_timestamp=None, receive_time=None, capture_time=None, sender_capture_time_offset=None, mime_type=None, frame_id=None, dependencies=None, width=None, height=None, spatial_index=None, temporal_index=None, timestamp=None)

The metadata of an RTCEncodedVideoFrame. It adds to the members of RTCEncodedFrameMetadata.

See MDN: RTCEncodedVideoFrame/getMetadata.

Parameters:
  • frame_id (int, optional) – The identifier of the frame, which dependencies of later frames refer to.

  • dependencies (list of int, optional) – The frame_id values of the frames this one depends on.

  • width (int, optional) – The width of the frame, in pixels.

  • height (int, optional) – The height of the frame, in pixels.

  • spatial_index (int, optional) – The spatial layer of the frame.

  • temporal_index (int, optional) – The temporal layer of the frame.

  • timestamp (int, optional) – The presentation timestamp of the frame, in microseconds.

class webrtc.models.rtc_encoded_frame.RTCEncodedAudioFrameMetadata(synchronization_source=None, payload_type=None, contributing_sources=None, rtp_timestamp=None, receive_time=None, capture_time=None, sender_capture_time_offset=None, mime_type=None, sequence_number=None, audio_level=None)

The metadata of an RTCEncodedAudioFrame. It adds to the members of RTCEncodedFrameMetadata.

See MDN: RTCEncodedAudioFrame/getMetadata.

Parameters:
  • sequence_number (int, optional) – The RTP sequence number of a received frame.

  • audio_level (float, optional) – The audio level of the frame, from 0 (silence) to 1 (0 dBov).

class webrtc.models.rtc_encoded_frame.RTCEncodedVideoFrameOptions(metadata=None)

The options for copying an RTCEncodedVideoFrame.

See MDN: RTCEncodedVideoFrame/RTCEncodedVideoFrame.

Parameters:

metadata (RTCEncodedVideoFrameMetadata, optional) – Metadata for the copy. Each member that isn’t None replaces that of the original frame.

class webrtc.models.rtc_encoded_frame.RTCEncodedAudioFrameOptions(metadata=None)

The options for copying an RTCEncodedAudioFrame.

See MDN: RTCEncodedAudioFrame/RTCEncodedAudioFrame.

Parameters:

metadata (RTCEncodedAudioFrameMetadata, optional) – Metadata for the copy. Each member that isn’t None replaces that of the original frame.

class webrtc.models.rtc_encoded_frame.RTCEncodedVideoFrame(original_frame, options=None)

An encoded video frame, read from an webrtc.RTCRtpScriptTransformer and written back to it.

The constructor copies a frame with its payload and metadata. A copy belongs to no sender or receiver, so writing it to a transformer drops it.

See MDN: RTCEncodedVideoFrame.

Parameters:
Raises:
property type: EncodedVideoChunkType

Whether it’s a key frame or a delta frame.

See MDN: RTCEncodedVideoFrame/type.

Type:

webrtc.EncodedVideoChunkType

get_metadata()

Returns the metadata of the frame.

See MDN: RTCEncodedVideoFrame/getMetadata.

Returns:

RTCEncodedVideoFrameMetadata – A copy, so changing it doesn’t change the frame.

Return type:

RTCEncodedVideoFrameMetadata

class webrtc.models.rtc_encoded_frame.RTCEncodedAudioFrame(original_frame, options=None)

An encoded audio frame, read from an webrtc.RTCRtpScriptTransformer and written back to it.

The constructor copies a frame with its payload and metadata. A copy belongs to no sender or receiver, so writing it to a transformer drops it.

See MDN: RTCEncodedAudioFrame.

Parameters:
Raises:
get_metadata()

Returns the metadata of the frame.

See MDN: RTCEncodedAudioFrame/getMetadata.

Returns:

RTCEncodedAudioFrameMetadata – A copy, so changing it doesn’t change the frame.

Return type:

RTCEncodedAudioFrameMetadata