Skip to content

fix: resolve FFmpeg MIME type error and persist core files in IndexedDB#49

Merged
Naptie merged 2 commits intomainfrom
copilot/fix-ffmpeg-loading-error
Mar 21, 2026
Merged

fix: resolve FFmpeg MIME type error and persist core files in IndexedDB#49
Naptie merged 2 commits intomainfrom
copilot/fix-ffmpeg-loading-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 21, 2026

loadFFmpeg created blob URLs without MIME types, causing browsers to reject the core JS as a module script (Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of ""). Additionally, FFmpeg core+WASM were re-downloaded on every use.

MIME type fix

Blobs are now wrapped with correct MIME types before createObjectURL:

const ensureMimeType = (blob: Blob, mimeType: string): Blob =>
  blob.type === mimeType ? blob : new Blob([blob], { type: mimeType });

const coreURL = URL.createObjectURL(ensureMimeType(core, 'text/javascript'));
const wasmURL = URL.createObjectURL(ensureMimeType(wasm, 'application/wasm'));

IndexedDB caching

  • src/lib/services/idb.ts — Extracted shared openDB from respackStorage.ts. DB version bumped 1→2 to add ffmpeg object store.
  • src/lib/services/ffmpegStorage.ts — Key-value blob storage for FFmpeg files, reusing the shared DB.
  • src/lib/services/respackStorage.ts — Now imports openDB from idb.ts.
  • src/lib/player/services/ffmpeg/index.tsloadFFmpeg(core?, wasm?) now checks IndexedDB cache first, downloads and caches on miss, and caches caller-provided blobs. This also fixes the existing bug where utils.ts called loadFFmpeg() with no arguments against a signature that required them.
  • src/routes/(app)/+page.svelte — Simplified to just await loadFFmpeg() since caching is handled internally.

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

@vercel
Copy link

vercel bot commented Mar 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
player Ready Ready Preview, Comment Mar 21, 2026 5:41pm

- Fix MIME type error by ensuring correct types (text/javascript, application/wasm)
  when creating blob URLs for FFmpeg module loading
- Add IndexedDB persistence for FFmpeg core JS and WASM files to avoid
  re-downloading on every load
- Extract shared openDB helper from respackStorage into idb.ts
- Create ffmpegStorage.ts for FFmpeg blob cache using shared IndexedDB
- Make loadFFmpeg() work without arguments by falling back to cache/download

Co-authored-by: Naptie <57532127+Naptie@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PhiZone/player/sessions/40cc73f4-8857-46c3-8178-25246cf5975d
Copilot AI changed the title [WIP] Fix FFmpeg loading error and implement IndexedDB persistence fix: resolve FFmpeg MIME type error and persist core files in IndexedDB Mar 21, 2026
Copilot AI requested a review from Naptie March 21, 2026 17:42
@Naptie Naptie marked this pull request as ready for review March 21, 2026 17:47
@Naptie Naptie merged commit 0eb4f05 into main Mar 21, 2026
3 checks passed
@Naptie Naptie deleted the copilot/fix-ffmpeg-loading-error branch March 21, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants