-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(example): remove complex private fields and tweak examples
- Loading branch information
1 parent
7535fca
commit a28783e
Showing
16 changed files
with
267 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"include": ["src/"], | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"esModuleInterop": true, | ||
"isolatedModules": true, | ||
"jsx": "react-jsx", | ||
"lib": ["ESNext", "DOM, DOM.Iterable"], | ||
"module": "ESNext", | ||
"moduleResolution": "node", | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitAny": true, | ||
"noImplicitOverride": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"outDir": "dist/", | ||
"resolveJsonModule": true, | ||
"rootDir": "src/", | ||
"skipLibCheck": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "ESNext" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,8 +76,8 @@ export function saveFrames( | |
} | ||
|
||
export async function saveVideo( | ||
canvas: HTMLCanvasElement, | ||
tick: (canvas: HTMLCanvasElement, f: number, dt: number) => void, | ||
canvas: HTMLCanvasElement | OffscreenCanvas, | ||
tick: (canvas: HTMLCanvasElement | OffscreenCanvas, f: number, dt: number) => void, | ||
filename?: string, | ||
options: VideoOptions = {} | ||
) { | ||
|
@@ -89,8 +89,8 @@ export async function saveVideo( | |
const fileName = filename ?? `output.${fileType}`; | ||
|
||
const ffmpeg = await (async () => { | ||
const BASE_URL = ""; | ||
// const BASE_URL = "https://unpkg.com/@ffmpeg/[email protected]/dist/esm"; | ||
// const BASE_URL = "/kdim"; | ||
const BASE_URL = "https://unpkg.com/@ffmpeg/[email protected]/dist/esm"; | ||
const ffmpeg = new FFmpeg(); | ||
await ffmpeg.load({ | ||
coreURL: await toBlobURL(`${BASE_URL}/ffmpeg-core.js`, 'text/javascript'), | ||
|
@@ -102,15 +102,20 @@ export async function saveVideo( | |
|
||
async function writeFrame(): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
canvas.toBlob( | ||
canvas instanceof HTMLCanvasElement ? canvas.toBlob( | ||
async (blob) => { | ||
if (!blob) { | ||
reject(new Error("Unable to create Blob from canvas")); | ||
} | ||
const data = await fetchFile(blob!); | ||
await ffmpeg.writeFile(`${f}.png`, data); | ||
resolve(); | ||
}, "png", frameOptions.quality); | ||
}, "png", frameOptions.quality) : (async () => { | ||
const blob = await canvas.convertToBlob(frameOptions); | ||
const data = await fetchFile(blob); | ||
await ffmpeg.writeFile(`${f}.png`, data); | ||
resolve(); | ||
})(); | ||
}); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.