demo · v136

HEVC in WebRTC

Enumerate every codec your RTCRtpSender and RTCRtpReceiver can actually negotiate. H265/HEVC will appear here when hardware support is present (often only on a recent GPU).

Probing…

Video send/receive capabilities

mimeTypesendreceive

Negotiate a real PeerConnection

verdict

the code

const caps = RTCRtpSender.getCapabilities("video");
const hevc = caps.codecs.find(c => c.mimeType === "video/H265");

if (hevc) {
  const pc = new RTCPeerConnection();
  const t = pc.addTransceiver("video", { direction: "sendrecv" });
  // 136+: prefer HEVC, fall back to VP9/H264 if peer can't
  t.setCodecPreferences([hevc, ...caps.codecs.filter(c => c !== hevc)]);
}

see also