Skip to content

Commit 59a729b

Browse files
Merge videoUploading samples together (#364)
1 parent 5f11215 commit 59a729b

File tree

4 files changed

+17
-156
lines changed

4 files changed

+17
-156
lines changed

next.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ module.exports = {
88
basePath: BASE_PATH,
99
compress: true,
1010
reactStrictMode: true,
11+
async redirects() {
12+
return [
13+
{
14+
source: '/samples/videoUploadingWebCodecs',
15+
destination: '/samples/videoUploading?videoSource=videoFrame',
16+
permanent: true,
17+
},
18+
]
19+
},
1120
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
1221
config.module.rules.push({
1322
test: /\.(png|jpe?g|gif|webm)$/i,

src/pages/samples/[slug].tsx

-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ const gpuComputeDemoPages: PageComponentType = {
7272
const webPlatformPages: PageComponentType = {
7373
resizeCanvas: dynamic(() => import('../../sample/resizeCanvas/main')),
7474
videoUploading: dynamic(() => import('../../sample/videoUploading/main')),
75-
videoUploadingWebCodecs: dynamic(
76-
() => import('../../sample/videoUploadingWebCodecs/main')
77-
),
7875
worker: dynamic(() => import('../../sample/worker/main')),
7976
};
8077

src/sample/videoUploading/main.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
5858
minFilter: 'linear',
5959
});
6060

61+
const params = new URLSearchParams(window.location.search);
62+
6163
const settings = {
6264
requestFrame: 'requestAnimationFrame',
65+
videoSource: params.get('videoSource') || 'videoElement',
6366
};
6467

68+
gui.add(settings, 'videoSource', ['videoElement', 'videoFrame']);
6569
gui.add(settings, 'requestFrame', [
6670
'requestAnimationFrame',
6771
'requestVideoFrameCallback',
@@ -71,6 +75,9 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
7175
// Sample is no longer the active page.
7276
if (!pageState.active) return;
7377

78+
const externalTextureSource =
79+
settings.videoSource === 'videoFrame' ? new VideoFrame(video) : video;
80+
7481
const uniformBindGroup = device.createBindGroup({
7582
layout: pipeline.getBindGroupLayout(0),
7683
entries: [
@@ -81,7 +88,7 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
8188
{
8289
binding: 2,
8390
resource: device.importExternalTexture({
84-
source: video,
91+
source: externalTextureSource,
8592
}),
8693
},
8794
],

src/sample/videoUploadingWebCodecs/main.ts

-152
This file was deleted.

0 commit comments

Comments
 (0)