Re: [mediacapture-transform] How to handle varying pixel formats (#83)

Regarding conversion by the web app, a relatively easy and efficient way of converting to RGBA is through WebGPU (well, "relatively easy" provided you're familiar with a few WebGPU concepts, and "efficient" when the underlying data of the `VideoFrame` is on the GPU). The [external texture sampler]( returns pixels in RGBA (or BGRA) with the specified color space, regardless of the pixel format of the external texture.

Here is a code example of [a transformer function that converts a `VideoFrame` to RGBA with WebGPU]( Most lines are "boilerplate" code to use WebGPU. The actual conversion is done by the [fragment shader]( and does not require specific knowledge of pixel formats and conversion formulas:

fn frag_main(@location(0) uv : vec2<f32>) -> @location(0) vec4<f32> {
  return textureSampleBaseClampToEdge(myTexture, mySampler, uv);

GitHub Notification of comment by tidoust
Please view or discuss this issue at using your GitHub account

Sent via github-notify-ml as configured in

Received on Thursday, 2 February 2023 10:24:50 UTC