Revert "feat: switch video compression to webcodecs"

This reverts commit 3f35add587.
This commit is contained in:
tim
2025-09-11 17:20:08 +08:00
parent 7d5c864f64
commit 90bd41e740
8 changed files with 435 additions and 134 deletions

View File

@@ -0,0 +1,37 @@
import { FFmpeg } from '@ffmpeg/ffmpeg'
import { toBlobURL } from '@ffmpeg/util'
import { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'
let ffmpeg: FFmpeg | null = null
export default defineNuxtPlugin(() => {
const {
public: { ffmpegVersion },
} = useRuntimeConfig()
return {
provide: {
ffmpeg: async () => {
if (ffmpeg) return ffmpeg
ffmpeg = new FFmpeg()
const mtOk =
typeof crossOriginIsolated !== 'undefined' &&
crossOriginIsolated &&
typeof SharedArrayBuffer !== 'undefined'
const pkg = mtOk ? '@ffmpeg/core-mt' : '@ffmpeg/core-st'
const base = `https://unpkg.com/${pkg}@${ffmpegVersion}/dist/umd`
await ffmpeg.load({
coreURL: await toBlobURL(`${base}/ffmpeg-core.js`, 'text/javascript'),
wasmURL: await toBlobURL(`${base}/ffmpeg-core.wasm`, 'application/wasm'),
workerURL: await toBlobURL(`${base}/ffmpeg-core.worker.js`, 'text/javascript'),
})
return ffmpeg
},
},
}
})