由于在caniuse查到,chrome从70版本就开始支持AV1,所以想尝试WebRTC传输AV1编码数据.
$ caniuse AV1
AV1 video format ✔ 32.97% ◒ 0.08% [Other]
AV1 (AOMedia Video 1) is a royalty-free video format by the Alliance for Open Media, meant to succeed its predecessor VP9 and compete with the HEVC/H.265 format. #Other
IE ✘
Edge ✘ 12+ ✘ 18+¹ ✔ 79+
Firefox ✘ 2+ ✘ 55+⁵ ✘ 61+⁴ ✘ 63+⁴ ◒ 65+² ◒ 66+³ ✔ 67+
Chrome ✘ 4+ ✘ 67+⁶ ✔ 70+
Safari ✘
Opera ✘ 9+ ✔ 57+
¹Supported in Edge when the AV1 Video Extension (Beta) is installed from the Microsoft Store
²Partial support in Firefox 65 refers to being enabled by default only for Windows 64-bit users (see "Known Issues" for lack of 32-bit support.)
³Partial support in Firefox 66 refers to being enabled by default only for Windows and macOS users
⁴Can be enabled in Firefox via the `media.av1.enabled` flag in `about:config`
⁵Only available in Firefox Nightly (applies to older versions of Firefox)
⁶Can be enabled in Chrome via the `#enable-av1-decoder` flag in `chrome://flags`
但是没有看到浏览器客户端的RtpCapabilities中有AV1的值.
简单查阅了一下mediasoup的mediasoup-client源码.
客户端获得Capabilities是通过RTCPeerConnection获得的.
源码如下:
async getNativeRtpCapabilities() {
logger.debug('getNativeRtpCapabilities()');
const pc = new RTCPeerConnection({
iceServers: [],
iceTransportPolicy: 'all',
bundlePolicy: 'max-bundle',
rtcpMuxPolicy: 'require',
sdpSemantics: 'unified-plan'
});
try {
pc.addTransceiver('audio');
pc.addTransceiver('video');
const offer = await pc.createOffer();
try {
pc.close();
}
catch (error) { }
const sdpObject = sdpTransform.parse(offer.sdp);
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities({ sdpObject });
return nativeRtpCapabilities;
}
catch (error) {
try {
pc.close();
}
catch (error2) { }
throw error;
}
}
1,创建RTCPeerConnection
2,添加video和audio轨道
3,生成offer
4,解析offer中的sdp获得浏览器的RtpCapabilities.
确实没有AV1,但是把AV1文件放在浏览器里能播放确实能播放.
或许浏览器的webrtc目前还未支持AV1.
微信号:yjkhtddx
欢迎加好友技术交流