ycw před 1 rokem
rodič
revize
98a3fa37f7
1 změnil soubory, kde provedl 22 přidání a 2 odebrání
  1. 22 2
      examples/webgpu_video_frame.html

+ 22 - 2
examples/webgpu_video_frame.html

@@ -50,6 +50,9 @@
 				const decoder = new VideoDecoder( {
 					output( frame ) {
 
+						// To avoid video decoder stalls, we should close the VideoFrame which is no longer needed. https://w3c.github.io/webcodecs/#dom-videodecoder-decode
+						if ( videoTexture.image instanceof VideoFrame ) videoTexture.image.close();
+
 						videoTexture.setFrame( frame );
 			
 					},
@@ -71,9 +74,26 @@
 						decoder.decode( chunk );
 
 					},
-					setStatus( s ) {
+					setStatus( kind, status ) {
+
+						console.info( 'MP4Demuxer:', kind );
+
+						if ( kind === 'fetch' && status === 'Done' ) {
+
+							decoder.flush().then( () => {
+
+								decoder.close();
+
+								// In case our VideoFrameTexture is no longer needed, we should close its backed VideoFrame, see issue #30379:
+								if ( videoTexture.image instanceof VideoFrame ) videoTexture.image.close();
+
+								videoTexture.image = null;
+
+								scene.remove( mesh );
+
+							} );
 
-						console.info( 'MP4Demuxer:', s );
+						}
 
 					}
 				} );

粤ICP备19079148号