1 parent
8652ee74c6
commit
bbb4d8cf6c
3 files changed
+14
-6
No files matched your search
@@ -8,6 +8,7 @@
|
|||||||
"@ant-design/icons": "^6.3.2",
|
"@ant-design/icons": "^6.3.2",
|
||||||
"@codemirror/lang-json": "^6.0.2",
|
"@codemirror/lang-json": "^6.0.2",
|
||||||
"@excalidraw/excalidraw": "0.18.1",
|
"@excalidraw/excalidraw": "0.18.1",
|
||||||
|
"@ffmpeg/core": "0.12.10",
|
||||||
"@ffmpeg/ffmpeg": "^0.12.15",
|
"@ffmpeg/ffmpeg": "^0.12.15",
|
||||||
"@ffmpeg/util": "^0.12.2",
|
"@ffmpeg/util": "^0.12.2",
|
||||||
"@mediapipe/tasks-vision": "^1.0.1",
|
"@mediapipe/tasks-vision": "^1.0.1",
|
||||||
@@ -207,6 +208,8 @@
|
|||||||
|
|
||||||
"@excalidraw/random-username": ["@excalidraw/random-username@1.1.0", "", {}, "sha512-nULYsQxkWHnbmHvcs+efMkJ4/9TtvNyFeLyHdeGxW0zHs6P+jYVqcRff9A6Vq9w9JXeDRnRh2VKvTtS19GW2qA=="],
|
"@excalidraw/random-username": ["@excalidraw/random-username@1.1.0", "", {}, "sha512-nULYsQxkWHnbmHvcs+efMkJ4/9TtvNyFeLyHdeGxW0zHs6P+jYVqcRff9A6Vq9w9JXeDRnRh2VKvTtS19GW2qA=="],
|
||||||
|
|
||||||
|
"@ffmpeg/core": ["@ffmpeg/core@0.12.10", "", {}, "sha512-dzNplnn2Nxle2c2i2rrDhqcB19q9cglCkWnoMTDN9Q9l3PvdjZWd1HfSPjCNWc/p8Q3CT+Es9fWOR0UhAeYQZA=="],
|
||||||
|
|
||||||
"@ffmpeg/ffmpeg": ["@ffmpeg/ffmpeg@0.12.15", "", { "dependencies": { "@ffmpeg/types": "^0.12.4" } }, "sha512-1C8Obr4GsN3xw+/1Ww6PFM84wSQAGsdoTuTWPOj2OizsRDLT4CXTaVjPhkw6ARyDus1B9X/L2LiXHqYYsGnRFw=="],
|
"@ffmpeg/ffmpeg": ["@ffmpeg/ffmpeg@0.12.15", "", { "dependencies": { "@ffmpeg/types": "^0.12.4" } }, "sha512-1C8Obr4GsN3xw+/1Ww6PFM84wSQAGsdoTuTWPOj2OizsRDLT4CXTaVjPhkw6ARyDus1B9X/L2LiXHqYYsGnRFw=="],
|
||||||
|
|
||||||
"@ffmpeg/types": ["@ffmpeg/types@0.12.4", "", {}, "sha512-k9vJQNBGTxE5AhYDtOYR5rO5fKsspbg51gbcwtbkw2lCdoIILzklulcjJfIDwrtn7XhDeF2M+THwJ2FGrLeV6A=="],
|
"@ffmpeg/types": ["@ffmpeg/types@0.12.4", "", {}, "sha512-k9vJQNBGTxE5AhYDtOYR5rO5fKsspbg51gbcwtbkw2lCdoIILzklulcjJfIDwrtn7XhDeF2M+THwJ2FGrLeV6A=="],
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"@ant-design/icons": "^6.3.2",
|
"@ant-design/icons": "^6.3.2",
|
||||||
"@codemirror/lang-json": "^6.0.2",
|
"@codemirror/lang-json": "^6.0.2",
|
||||||
"@excalidraw/excalidraw": "0.18.1",
|
"@excalidraw/excalidraw": "0.18.1",
|
||||||
|
"@ffmpeg/core": "0.12.10",
|
||||||
"@ffmpeg/ffmpeg": "^0.12.15",
|
"@ffmpeg/ffmpeg": "^0.12.15",
|
||||||
"@ffmpeg/util": "^0.12.2",
|
"@ffmpeg/util": "^0.12.2",
|
||||||
"@mediapipe/tasks-vision": "^1.0.1",
|
"@mediapipe/tasks-vision": "^1.0.1",
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { FFmpeg } from "@ffmpeg/ffmpeg";
|
import { FFmpeg } from "@ffmpeg/ffmpeg";
|
||||||
import { fetchFile, toBlobURL } from "@ffmpeg/util";
|
import ffmpegCoreURL from "@ffmpeg/core?url";
|
||||||
|
import ffmpegWasmURL from "@ffmpeg/core/wasm?url";
|
||||||
|
import { fetchFile } from "@ffmpeg/util";
|
||||||
import { getMediaBlob } from "@/services/file-storage";
|
import { getMediaBlob } from "@/services/file-storage";
|
||||||
|
|
||||||
export type MergeVideoInput = { id: string; url?: string; storageKey?: string };
|
export type MergeVideoInput = { id: string; url?: string; storageKey?: string };
|
||||||
@@ -12,12 +14,14 @@ async function loadFFmpeg(onProgress?: (progress: MergeVideoProgress) => void) {
|
|||||||
if (!ffmpegPromise) {
|
if (!ffmpegPromise) {
|
||||||
ffmpegPromise = (async () => {
|
ffmpegPromise = (async () => {
|
||||||
const ffmpeg = new FFmpeg();
|
const ffmpeg = new FFmpeg();
|
||||||
const baseURL = "https://unpkg.com/@ffmpeg/core@0.12.10/dist/umd";
|
|
||||||
onProgress?.({ phase: "loading", progress: 0 });
|
onProgress?.({ phase: "loading", progress: 0 });
|
||||||
await ffmpeg.load({
|
try {
|
||||||
coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"),
|
// 核心资产随前端同源发布,避免自部署环境首次合并依赖第三方 CDN。
|
||||||
wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"),
|
await ffmpeg.load({ coreURL: ffmpegCoreURL, wasmURL: ffmpegWasmURL });
|
||||||
});
|
} catch (cause) {
|
||||||
|
ffmpeg.terminate();
|
||||||
|
throw new Error("视频合并工具加载失败,请刷新页面后重试", { cause });
|
||||||
|
}
|
||||||
return ffmpeg;
|
return ffmpeg;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user