File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 >
3433 </ head >
3534 < body >
3635 < canvas > </ canvas >
36+ < pre id =videoinfo > </ pre >
3737 </ body >
3838</ html >
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ const videos = {
2626 } ,
2727} as const ;
2828
29+ const videoinfo = document . getElementById ( 'videoinfo' ) as HTMLPreElement ;
30+
2931const canvas = document . querySelector ( 'canvas' ) as HTMLCanvasElement ;
3032const context = canvas . getContext ( 'webgpu' ) ;
3133const 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 ;
You can’t perform that action at this time.
0 commit comments