Skip to content

Commit ce659de

Browse files
committed
show frame dimensions
1 parent 0057478 commit ce659de

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎sample/videoUploading/index.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
height: 100%; /* make body fill the browser window */
2424
}
2525
canvas {
26-
width: 100%;
27-
height: 100%;
28-
max-width: 100%;
26+
width: min(100vw, 100vh);
27+
aspect-ratio: 4 / 3;
2928
display: block;
3029
}
3130
</style>
@@ -34,5 +33,6 @@
3433
</head>
3534
<body>
3635
<canvas></canvas>
36+
<pre id=videoinfo></pre>
3737
</body>
3838
</html>

‎sample/videoUploading/main.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const videos = {
2626
},
2727
} as const;
2828

29+
const videoinfo = document.getElementById('videoinfo') as HTMLPreElement;
30+
2931
const canvas = document.querySelector('canvas') as HTMLCanvasElement;
3032
const context = canvas.getContext('webgpu');
3133
const presentationFormat = navigator.gpu.getPreferredCanvasFormat();
@@ -138,8 +140,22 @@ function drawVideo() {
138140
const maxSize = device.limits.maxTextureDimension2D;
139141
canvas.width = Math.min(Math.max(1, canvas.offsetWidth), maxSize);
140142
canvas.height = Math.min(Math.max(1, canvas.offsetHeight), maxSize);
141-
const externalTextureSource =
142-
settings.videoSource === 'videoFrame' ? new VideoFrame(video) : video;
143+
const videoFrame =
144+
settings.videoSource === 'videoFrame' ? new VideoFrame(video) : null;
145+
const externalTextureSource = videoFrame ?? video;
146+
videoinfo.textContent = `HTMLVideoElement: ${video.videoWidth}x${video.videoHeight}`;
147+
if (videoFrame) {
148+
videoinfo.textContent +=
149+
'\nVideoFrame: ' +
150+
JSON.stringify(
151+
{
152+
codedRect: videoFrame.codedRect,
153+
visibleRect: videoFrame.visibleRect,
154+
},
155+
undefined,
156+
2
157+
);
158+
}
143159

144160
const mode = videos[settings.video].mode;
145161
const pipeline = mode === '360' ? video360Pipeline : videoCoverPipeline;

0 commit comments

Comments
 (0)