Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: bundle @ffmpeg/core instead of CDN #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"vite-plugin-static-copy": "^1.0.6"
},
"dependencies": {
"@ffmpeg/core": "^0.12.6",
"@ffmpeg/ffmpeg": "^0.12.10",
"@ffmpeg/util": "^0.12.1",
"@sentry/browser": "^7.110.0",
"canvas-confetti": "^1.9.2",
"json5": "^2.2.3",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions src/ffmpeg.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import { FFmpeg } from "@ffmpeg/ffmpeg";
import { fetchFile, toBlobURL } from '@ffmpeg/util';
import { updateStore } from "./store";
import workerURL from '@ffmpeg/ffmpeg/worker?url';

export async function initFFmpeg() {
let ffmpeg = new FFmpeg()
const CORE_VERSION = '0.12.6'
const baseURL = 'https://unpkg.com/@ffmpeg/core@' + CORE_VERSION + '/dist/esm'

// Load the WASM file and coreURL
const [coreURL, wasmURL] = await Promise.all([
toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript'),
toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm'),
])

await ffmpeg.load({
coreURL,
wasmURL,
coreURL: './ffmpeg-core.js',
wasmURL: './ffmpeg-core.wasm',
classWorkerURL: import.meta.env.PROD ? undefined : workerURL, // vite bug
});

Expand Down
7 changes: 6 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export default defineConfig({
devtools(),
solidPlugin(),
viteStaticCopy({
targets: [{ src: './LICENSE', dest: './' }]
targets: [
{ src: './LICENSE', dest: './' },

{ src: './node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js', dest: './assets' },
{ src: './node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.wasm', dest: './assets' },
]
})
],
server: {
Expand Down
Loading