This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://web.dev/mediastreamtrack-insertable-media-processing/ | |
// Uses Webcodecs API, which is supported only in Chrome as of November 2021 | |
function convertI420AFrameToI420Frame(frame) { | |
const { width, height } = frame.codedRect; | |
// Y, U, V, Alpha values are stored sequentially. Take only YUV values | |
const buffer = new Uint8Array(width * height * 3); | |
frame.copyTo(buffer, { rect: frame.codedRect }); | |
const init = { | |
timestamp: 0, |