w3c / mediacapture-extensions

Extensions to Media Capture and Streams by the WebRTC Working Group
https://w3c.github.io/mediacapture-extensions/
Other
19 stars 14 forks source link

mediastream cannot handle webcam data stream in yuv pixel format correctly #99

Open Danjuanlab opened 1 year ago

Danjuanlab commented 1 year ago

Currently using webrtc to open the local webcam device, only when the pixel format of the webcam is srgb or mjpeg, the color rendered to the canvas or video is correct. When the connected webcam is a hardware camera capture card, or an obs virtual camera. Both of these are transmitted in yuv pixel format. When the GPU hardware acceleration of the browser is turned off, the colors rendered to the video and canvas are wrong. When the browser hardware acceleration is turned on, the color rendering in the video tag is correct, but the canvas is still wrong.

Since the mediastream object does not provide restrictions such as pixel format or color space, and so far I have not found any method to directly read the raw data byte stream in the mediaStream, so as a developer, it is impossible to judge whether the webcam opened by the user is What pixel format, and then do subsequent color conversion.

image image

屏幕截图 2022-03-14 112300333