-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VideoFrame should use display size, not coded size #4525
Comments
That sounds correct from an expected behavior standpoint. |
I feel like I'd expect the coded size and if I want to display that coded size correctly then I'd apply the display size to CSS. Otherwise it's lossy. |
@greggman Not sure I understand. The coded size for a 1920x1080 video is typically 1920x1088 (120x68 16x16 macroblocks). The last half block of the last row is garbage data that is not part of the video and for most purposes doesn't exist. From the web's perspective I think it was totally invisible until WebCodecs came along. Tangentially, while looking that up, I found some explanation of the aspect ratio thing that Kelsey remembered but didn't know the details of, here: w3c/webcodecs#26 Then, the question Kelsey raised would be, should the |
HTML is pretty clear that 2d canvas drawImage uses the "natural size" which must certainly be the display size. But I wouldn't be super confident that real WebGL implementations match that. @shaoboyan I wonder if you could find or create a video with non-square pixels so we can test this in WebGPU? I don't see one in the WebGL test resources, which means it needs one, too. It seems to simply require the |
@kainino0x
Drop the video into browser page directly and the chrome://media-internal page shows that:
So, the info said |
I definitely don't want garbage. I guess in my mind there are more sizes. I can imagine
I'd expect to get 2, not 3? |
Nice @shaoboyan, that'll be a useful test case. I'm also curious to see how it interacts with rotation (I'm guessing it applies before rotation, but not sure). Before we land a decision here, I'd like to know the results of drawImage, texImage2D, copyExternalImageToTexture, and importExternalTexture in each browser's current implementations. I don't know what to expect, but it would be nice if they're all consistent (with the possible exception of textureDimensions and textureLoad on external_texture).
I'm unsure whether it's possible for the visible rect size and natural size to be very different, or if they have to be equal in one dimension like they are in Shaobo's test. |
@greggman
Per my experiment, I think the 3 situation only happens when we define the |
@kainino0x @greggman @kdashg I reused a exist uploading sample with some changes (e.g. remove video size assignment). And I added a canvas2d context rendering logic like this:
Canvases are all the same size as I still use the cts resource. By executing the commands:
I got a video frame with info (by
According to video info, Getting the video element and query size get Using multiple way to 'draw' this frame: |
This is fantastic, thank you! Could you put the test pages up somewhere so they can be easily run in other browsers or in local builds? (like github pages, or send it to me and I can put it on github pages) This is the most interesting outcome:
This sounds like the texSubImage2D call is treating the video as having a resolution that doesn't match the texture you've allocated with texStorage2D (which is the videoWidth/videoHeight, the intrinsic size). But also it might be a Chromium bug with the unpack parameters? Because video_webgl.js doesn't seem to use unpack parameters at all. |
Sure, I'll send the sample after some code clean up |
@kainino0x Pls ref to https://shaoboyan.github.io/webgpu-samples/?sample=webgl-texImage2D under the categary “Video uploading through various APIs”. The bottom of the page. |
Different frames of the video can technically have different sizes iirc. |
(Pls correct me if I'm wrong). (Based on above fact) |
GPU Web WG 2024-03-27
|
copyExternalImageToTexture()
currently uses the coded size ofVideoFrame
inputs.Coded size (codedWidth/codedHeight):
Display size (displayWidth/displayHeight):
copyExternalImageToTexture()
andimportExternalTexture()
.HTMLVideoElement
for any given frame of a video. So we should use it instead.The text was updated successfully, but these errors were encountered: