Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.streampixel.io/llms.txt

Use this file to discover all available pages before exploring further.

The SDK provides real-time WebRTC stream statistics for monitoring connection quality, performance, and diagnostics.

Getting stats with UIControl

The simplest way to get current statistics:
const stats = UIControl.getStreamStats();

console.log(stats);
// {
//   "Framerate": 60,
//   "Net RTT (ms)": 12,
//   "Frames Decoded": 15420,
//   "Frames dropped": 3,
//   "Received": 245678,
//   "Packets Lost": 0,
//   "Video codec": "H264 level-asymmetry-allowed=1...",
//   "Audio codec": "opus minptime=10;useinbandfec=1",
//   "Video resolution": "1920x1080",
//   "Video Bitrate (kbps)": 8500,
//   "Audio Bitrate (kbps)": 128,
//   "Duration": "00:05:32",
//   "Controls stream input": true,
//   "Video quantization parameter": 22
// }
getStreamStats() triggers the stats panel internally, collects the data, and returns a parsed JavaScript object.

Stats via event listener

For continuous monitoring, listen for the statsReceived event:
pixelStreaming.addEventListener('statsReceived', (e) => {
  const aggregated = e.data.aggregatedStats;

  // Video stats
  const video = aggregated.inboundVideoStats;
  console.log('Bitrate:', video.bitrate);
  console.log('Resolution:', video.frameWidth + 'x' + video.frameHeight);
  console.log('FPS:', video.framesPerSecond);
  console.log('Frames decoded:', video.framesDecoded);
  console.log('Frames dropped:', video.framesDropped);
  console.log('Packets lost:', video.packetsLost);

  // Audio stats
  const audio = aggregated.inboundAudioStats;
  console.log('Audio bitrate:', audio.bitrate);

  // Session stats
  const session = aggregated.sessionStats;
  console.log('RTT (ms):', session.currentRoundTripTime * 1000);
  console.log('Duration (s):', session.duration);

  // Codec info
  const codecs = aggregated.codecs;
  // codecs is a Map<codecId, { mimeType }>
  // Look up video codec: codecs.get(video.codecId)?.mimeType
});

Available stat fields

From getStreamStats() (parsed key-value object)

FieldTypeDescription
FrameratenumberCurrent video frames per second
Net RTT (ms)numberNetwork round-trip time in milliseconds
Frames DecodednumberTotal video frames decoded
Frames droppednumberTotal video frames dropped
ReceivednumberTotal data received
Packets LostnumberTotal packets lost
Video codecstringVideo codec and parameters
Audio codecstringAudio codec and parameters
Video resolutionstringCurrent video resolution (e.g., “1920x1080”)
Video Bitrate (kbps)numberCurrent video bitrate
Audio Bitrate (kbps)numberCurrent audio bitrate
DurationstringSession duration (HH:MM:SS format)
Controls stream inputbooleanWhether this client controls UE input
Video quantization parameternumberCurrent video QP value

From statsReceived event (aggregated stats object)

ObjectFieldDescription
inboundVideoStatsbitrateVideo bitrate (kbps)
frameWidthVideo frame width
frameHeightVideo frame height
framesPerSecondFPS
framesDecodedTotal frames decoded
framesDroppedTotal frames dropped
packetsLostTotal packets lost
codecIdReference to codec in codecs Map
inboundAudioStatsbitrateAudio bitrate (kbps)
codecIdReference to codec in codecs Map
sessionStatsdurationSession duration in seconds
currentRoundTripTimeRTT in seconds (multiply by 1000 for ms)
codecsMapMap<codecId, { mimeType }> — lookup codec names

Resolving codec names

The codecs field is a JavaScript Map, not a plain object. Use .get(codecId) to look up codec names — bracket notation will not work.
The codecId in stats is a raw identifier. To get the human-readable name:
pixelStreaming.addEventListener('statsReceived', (e) => {
  const stats = e.data.aggregatedStats;
  const videoCodecId = stats.inboundVideoStats.codecId;
  const codecInfo = stats.codecs.get(videoCodecId);
  console.log('Video codec:', codecInfo?.mimeType); // e.g., "video/H264"
});

Next steps

UIControl API

Reference for getStreamStats() and other helpers.

Troubleshooting

Diagnose connection and codec issues using stats.