Spaces:
Running
Running
nicehero
commited on
Commit
·
7698ac4
1
Parent(s):
5903d9a
ffmpeg
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- assets/core-mt/package/dist/esm/ffmpeg-core.js +0 -0
- assets/core-mt/package/dist/esm/ffmpeg-core.wasm +3 -0
- assets/core-mt/package/dist/esm/ffmpeg-core.worker.js +1 -0
- assets/core-mt/package/dist/umd/ffmpeg-core.js +0 -0
- assets/core-mt/package/dist/umd/ffmpeg-core.wasm +3 -0
- assets/core-mt/package/dist/umd/ffmpeg-core.worker.js +1 -0
- assets/core-mt/package/package.json +42 -0
- assets/core/package/dist/esm/ffmpeg-core.js +0 -0
- assets/core/package/dist/esm/ffmpeg-core.wasm +3 -0
- assets/core/package/dist/umd/ffmpeg-core.js +0 -0
- assets/core/package/dist/umd/ffmpeg-core.wasm +3 -0
- assets/core/package/package.json +42 -0
- assets/ffmpeg/package/dist/esm/classes.d.ts +145 -0
- assets/ffmpeg/package/dist/esm/classes.js +271 -0
- assets/ffmpeg/package/dist/esm/const.d.ts +21 -0
- assets/ffmpeg/package/dist/esm/const.js +22 -0
- assets/ffmpeg/package/dist/esm/empty.d.mts +3 -0
- assets/ffmpeg/package/dist/esm/empty.mjs +6 -0
- assets/ffmpeg/package/dist/esm/errors.d.ts +4 -0
- assets/ffmpeg/package/dist/esm/errors.js +4 -0
- assets/ffmpeg/package/dist/esm/index.d.ts +1 -0
- assets/ffmpeg/package/dist/esm/index.js +1 -0
- assets/ffmpeg/package/dist/esm/types.d.ts +123 -0
- assets/ffmpeg/package/dist/esm/types.js +9 -0
- assets/ffmpeg/package/dist/esm/utils.d.ts +4 -0
- assets/ffmpeg/package/dist/esm/utils.js +7 -0
- assets/ffmpeg/package/dist/esm/worker.d.ts +9 -0
- assets/ffmpeg/package/dist/esm/worker.js +147 -0
- assets/ffmpeg/package/dist/umd/814.ffmpeg.js +2 -0
- assets/ffmpeg/package/dist/umd/814.ffmpeg.js.map +1 -0
- assets/ffmpeg/package/dist/umd/ffmpeg.js +2 -0
- assets/ffmpeg/package/dist/umd/ffmpeg.js.map +1 -0
- assets/ffmpeg/package/package.json +64 -0
- assets/util/package/dist/cjs/const.d.ts +1 -0
- assets/util/package/dist/cjs/const.js +4 -0
- assets/util/package/dist/cjs/errors.d.ts +2 -0
- assets/util/package/dist/cjs/errors.js +5 -0
- assets/util/package/dist/cjs/index.d.ts +50 -0
- assets/util/package/dist/cjs/index.js +173 -0
- assets/util/package/dist/cjs/types.d.ts +8 -0
- assets/util/package/dist/cjs/types.js +2 -0
- assets/util/package/dist/esm/const.d.ts +1 -0
- assets/util/package/dist/esm/const.js +1 -0
- assets/util/package/dist/esm/errors.d.ts +2 -0
- assets/util/package/dist/esm/errors.js +2 -0
- assets/util/package/dist/esm/index.d.ts +50 -0
- assets/util/package/dist/esm/index.js +153 -0
- assets/util/package/dist/esm/types.d.ts +8 -0
- assets/util/package/dist/esm/types.js +1 -0
- assets/util/package/dist/umd/index.js +1 -0
assets/core-mt/package/dist/esm/ffmpeg-core.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
assets/core-mt/package/dist/esm/ffmpeg-core.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0d7d296e6ac2bfd0af658dee9c76b9873ff5912263042ab2cfd4c9b2078a4cff
|
3 |
+
size 32223257
|
assets/core-mt/package/dist/esm/ffmpeg-core.worker.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8")+"//# sourceURL="+f)},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"\n");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var module=Module["wasmModule"];Module["wasmModule"]=null;var instance=new WebAssembly.Instance(module,info);return receiveInstance(instance)};self.onunhandledrejection=e=>{throw e.reason??e};function handleMessage(e){try{if(e.data.cmd==="load"){let messageQueue=[];self.onmessage=e=>messageQueue.push(e);self.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"});for(let msg of messageQueue){handleMessage(msg)}self.onmessage=handleMessage};Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=function(){postMessage({cmd:"callHandler",handler:handler,args:[...arguments]})}}Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;(e.data.urlOrBlob?import(e.data.urlOrBlob):import("./ffmpeg-core.js")).then(exports=>exports.default(Module))}else if(e.data.cmd==="run"){Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["__emscripten_thread_mailbox_await"](e.data.pthread_ptr);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){throw ex}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="checkMailbox"){if(initializedJS){Module["checkMailbox"]()}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}}self.onmessage=handleMessage;
|
assets/core-mt/package/dist/umd/ffmpeg-core.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
assets/core-mt/package/dist/umd/ffmpeg-core.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0d7d296e6ac2bfd0af658dee9c76b9873ff5912263042ab2cfd4c9b2078a4cff
|
3 |
+
size 32223257
|
assets/core-mt/package/dist/umd/ffmpeg-core.worker.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8")+"//# sourceURL="+f)},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"\n");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var module=Module["wasmModule"];Module["wasmModule"]=null;var instance=new WebAssembly.Instance(module,info);return receiveInstance(instance)};self.onunhandledrejection=e=>{throw e.reason??e};function handleMessage(e){try{if(e.data.cmd==="load"){let messageQueue=[];self.onmessage=e=>messageQueue.push(e);self.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"});for(let msg of messageQueue){handleMessage(msg)}self.onmessage=handleMessage};Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=function(){postMessage({cmd:"callHandler",handler:handler,args:[...arguments]})}}Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}createFFmpegCore(Module)}else if(e.data.cmd==="run"){Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["__emscripten_thread_mailbox_await"](e.data.pthread_ptr);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){throw ex}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="checkMailbox"){if(initializedJS){Module["checkMailbox"]()}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}}self.onmessage=handleMessage;
|
assets/core-mt/package/package.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@ffmpeg/core-mt",
|
3 |
+
"version": "0.12.5",
|
4 |
+
"description": "FFmpeg WebAssembly version (multi thread)",
|
5 |
+
"main": "./dist/umd/ffmpeg-core.js",
|
6 |
+
"exports": {
|
7 |
+
".": {
|
8 |
+
"import": "./dist/esm/ffmpeg-core.js",
|
9 |
+
"require": "./dist/umd/ffmpeg-core.js"
|
10 |
+
},
|
11 |
+
"./wasm": {
|
12 |
+
"import": "./dist/esm/ffmpeg-core.wasm",
|
13 |
+
"require": "./dist/umd/ffmpeg-core.wasm"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"files": [
|
17 |
+
"dist"
|
18 |
+
],
|
19 |
+
"repository": {
|
20 |
+
"type": "git",
|
21 |
+
"url": "git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"
|
22 |
+
},
|
23 |
+
"keywords": [
|
24 |
+
"ffmpeg",
|
25 |
+
"WebAssembly",
|
26 |
+
"video",
|
27 |
+
"audio",
|
28 |
+
"transcode"
|
29 |
+
],
|
30 |
+
"author": "Jerome Wu <[email protected]>",
|
31 |
+
"license": "MIT",
|
32 |
+
"bugs": {
|
33 |
+
"url": "https://github.com/ffmpegwasm/ffmpeg.wasm/issues"
|
34 |
+
},
|
35 |
+
"engines": {
|
36 |
+
"node": ">=16.x"
|
37 |
+
},
|
38 |
+
"homepage": "https://github.com/ffmpegwasm/ffmpeg.wasm#readme",
|
39 |
+
"publishConfig": {
|
40 |
+
"access": "public"
|
41 |
+
}
|
42 |
+
}
|
assets/core/package/dist/esm/ffmpeg-core.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
assets/core/package/dist/esm/ffmpeg-core.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:69c0cbc9fe983ced7624c3406f1f0a425b3a6d676b4c50730b8cb68cce01f8ee
|
3 |
+
size 31742481
|
assets/core/package/dist/umd/ffmpeg-core.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
assets/core/package/dist/umd/ffmpeg-core.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:69c0cbc9fe983ced7624c3406f1f0a425b3a6d676b4c50730b8cb68cce01f8ee
|
3 |
+
size 31742481
|
assets/core/package/package.json
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@ffmpeg/core",
|
3 |
+
"version": "0.12.5",
|
4 |
+
"description": "FFmpeg WebAssembly version (single thread)",
|
5 |
+
"main": "./dist/umd/ffmpeg-core.js",
|
6 |
+
"exports": {
|
7 |
+
".": {
|
8 |
+
"import": "./dist/esm/ffmpeg-core.js",
|
9 |
+
"require": "./dist/umd/ffmpeg-core.js"
|
10 |
+
},
|
11 |
+
"./wasm": {
|
12 |
+
"import": "./dist/esm/ffmpeg-core.wasm",
|
13 |
+
"require": "./dist/umd/ffmpeg-core.wasm"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"files": [
|
17 |
+
"dist"
|
18 |
+
],
|
19 |
+
"repository": {
|
20 |
+
"type": "git",
|
21 |
+
"url": "git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"
|
22 |
+
},
|
23 |
+
"keywords": [
|
24 |
+
"ffmpeg",
|
25 |
+
"WebAssembly",
|
26 |
+
"video",
|
27 |
+
"audio",
|
28 |
+
"transcode"
|
29 |
+
],
|
30 |
+
"author": "Jerome Wu <[email protected]>",
|
31 |
+
"license": "MIT",
|
32 |
+
"bugs": {
|
33 |
+
"url": "https://github.com/ffmpegwasm/ffmpeg.wasm/issues"
|
34 |
+
},
|
35 |
+
"engines": {
|
36 |
+
"node": ">=16.x"
|
37 |
+
},
|
38 |
+
"homepage": "https://github.com/ffmpegwasm/ffmpeg.wasm#readme",
|
39 |
+
"publishConfig": {
|
40 |
+
"access": "public"
|
41 |
+
}
|
42 |
+
}
|
assets/ffmpeg/package/dist/esm/classes.d.ts
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { FSNode, FFMessageLoadConfig, OK, IsFirst, LogEventCallback, ProgressEventCallback, FileData, FFFSType, FFFSMountOptions, FFFSPath } from "./types.js";
|
2 |
+
type FFMessageOptions = {
|
3 |
+
signal?: AbortSignal;
|
4 |
+
};
|
5 |
+
/**
|
6 |
+
* Provides APIs to interact with ffmpeg web worker.
|
7 |
+
*
|
8 |
+
* @example
|
9 |
+
* ```ts
|
10 |
+
* const ffmpeg = new FFmpeg();
|
11 |
+
* ```
|
12 |
+
*/
|
13 |
+
export declare class FFmpeg {
|
14 |
+
#private;
|
15 |
+
loaded: boolean;
|
16 |
+
/**
|
17 |
+
* Listen to log or prgress events from `ffmpeg.exec()`.
|
18 |
+
*
|
19 |
+
* @example
|
20 |
+
* ```ts
|
21 |
+
* ffmpeg.on("log", ({ type, message }) => {
|
22 |
+
* // ...
|
23 |
+
* })
|
24 |
+
* ```
|
25 |
+
*
|
26 |
+
* @example
|
27 |
+
* ```ts
|
28 |
+
* ffmpeg.on("progress", ({ progress, time }) => {
|
29 |
+
* // ...
|
30 |
+
* })
|
31 |
+
* ```
|
32 |
+
*
|
33 |
+
* @remarks
|
34 |
+
* - log includes output to stdout and stderr.
|
35 |
+
* - The progress events are accurate only when the length of
|
36 |
+
* input and output video/audio file are the same.
|
37 |
+
*
|
38 |
+
* @category FFmpeg
|
39 |
+
*/
|
40 |
+
on(event: "log", callback: LogEventCallback): void;
|
41 |
+
on(event: "progress", callback: ProgressEventCallback): void;
|
42 |
+
/**
|
43 |
+
* Unlisten to log or prgress events from `ffmpeg.exec()`.
|
44 |
+
*
|
45 |
+
* @category FFmpeg
|
46 |
+
*/
|
47 |
+
off(event: "log", callback: LogEventCallback): void;
|
48 |
+
off(event: "progress", callback: ProgressEventCallback): void;
|
49 |
+
/**
|
50 |
+
* Loads ffmpeg-core inside web worker. It is required to call this method first
|
51 |
+
* as it initializes WebAssembly and other essential variables.
|
52 |
+
*
|
53 |
+
* @category FFmpeg
|
54 |
+
* @returns `true` if ffmpeg core is loaded for the first time.
|
55 |
+
*/
|
56 |
+
load: (config?: FFMessageLoadConfig, { signal }?: FFMessageOptions) => Promise<IsFirst>;
|
57 |
+
/**
|
58 |
+
* Execute ffmpeg command.
|
59 |
+
*
|
60 |
+
* @remarks
|
61 |
+
* To avoid common I/O issues, ["-nostdin", "-y"] are prepended to the args
|
62 |
+
* by default.
|
63 |
+
*
|
64 |
+
* @example
|
65 |
+
* ```ts
|
66 |
+
* const ffmpeg = new FFmpeg();
|
67 |
+
* await ffmpeg.load();
|
68 |
+
* await ffmpeg.writeFile("video.avi", ...);
|
69 |
+
* // ffmpeg -i video.avi video.mp4
|
70 |
+
* await ffmpeg.exec(["-i", "video.avi", "video.mp4"]);
|
71 |
+
* const data = ffmpeg.readFile("video.mp4");
|
72 |
+
* ```
|
73 |
+
*
|
74 |
+
* @returns `0` if no error, `!= 0` if timeout (1) or error.
|
75 |
+
* @category FFmpeg
|
76 |
+
*/
|
77 |
+
exec: (args: string[], timeout?: number, { signal }?: FFMessageOptions) => Promise<number>;
|
78 |
+
/**
|
79 |
+
* Terminate all ongoing API calls and terminate web worker.
|
80 |
+
* `FFmpeg.load()` must be called again before calling any other APIs.
|
81 |
+
*
|
82 |
+
* @category FFmpeg
|
83 |
+
*/
|
84 |
+
terminate: () => void;
|
85 |
+
/**
|
86 |
+
* Write data to ffmpeg.wasm.
|
87 |
+
*
|
88 |
+
* @example
|
89 |
+
* ```ts
|
90 |
+
* const ffmpeg = new FFmpeg();
|
91 |
+
* await ffmpeg.load();
|
92 |
+
* await ffmpeg.writeFile("video.avi", await fetchFile("../video.avi"));
|
93 |
+
* await ffmpeg.writeFile("text.txt", "hello world");
|
94 |
+
* ```
|
95 |
+
*
|
96 |
+
* @category File System
|
97 |
+
*/
|
98 |
+
writeFile: (path: string, data: FileData, { signal }?: FFMessageOptions) => Promise<OK>;
|
99 |
+
mount: (fsType: FFFSType, options: FFFSMountOptions, mountPoint: FFFSPath) => Promise<OK>;
|
100 |
+
unmount: (mountPoint: FFFSPath) => Promise<OK>;
|
101 |
+
/**
|
102 |
+
* Read data from ffmpeg.wasm.
|
103 |
+
*
|
104 |
+
* @example
|
105 |
+
* ```ts
|
106 |
+
* const ffmpeg = new FFmpeg();
|
107 |
+
* await ffmpeg.load();
|
108 |
+
* const data = await ffmpeg.readFile("video.mp4");
|
109 |
+
* ```
|
110 |
+
*
|
111 |
+
* @category File System
|
112 |
+
*/
|
113 |
+
readFile: (path: string, encoding?: string, { signal }?: FFMessageOptions) => Promise<FileData>;
|
114 |
+
/**
|
115 |
+
* Delete a file.
|
116 |
+
*
|
117 |
+
* @category File System
|
118 |
+
*/
|
119 |
+
deleteFile: (path: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
120 |
+
/**
|
121 |
+
* Rename a file or directory.
|
122 |
+
*
|
123 |
+
* @category File System
|
124 |
+
*/
|
125 |
+
rename: (oldPath: string, newPath: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
126 |
+
/**
|
127 |
+
* Create a directory.
|
128 |
+
*
|
129 |
+
* @category File System
|
130 |
+
*/
|
131 |
+
createDir: (path: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
132 |
+
/**
|
133 |
+
* List directory contents.
|
134 |
+
*
|
135 |
+
* @category File System
|
136 |
+
*/
|
137 |
+
listDir: (path: string, { signal }?: FFMessageOptions) => Promise<FSNode[]>;
|
138 |
+
/**
|
139 |
+
* Delete an empty directory.
|
140 |
+
*
|
141 |
+
* @category File System
|
142 |
+
*/
|
143 |
+
deleteDir: (path: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
144 |
+
}
|
145 |
+
export {};
|
assets/ffmpeg/package/dist/esm/classes.js
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { FFMessageType } from "./const.js";
|
2 |
+
import { getMessageID } from "./utils.js";
|
3 |
+
import { ERROR_TERMINATED, ERROR_NOT_LOADED } from "./errors.js";
|
4 |
+
/**
|
5 |
+
* Provides APIs to interact with ffmpeg web worker.
|
6 |
+
*
|
7 |
+
* @example
|
8 |
+
* ```ts
|
9 |
+
* const ffmpeg = new FFmpeg();
|
10 |
+
* ```
|
11 |
+
*/
|
12 |
+
export class FFmpeg {
|
13 |
+
#worker = null;
|
14 |
+
/**
|
15 |
+
* #resolves and #rejects tracks Promise resolves and rejects to
|
16 |
+
* be called when we receive message from web worker.
|
17 |
+
*/
|
18 |
+
#resolves = {};
|
19 |
+
#rejects = {};
|
20 |
+
#logEventCallbacks = [];
|
21 |
+
#progressEventCallbacks = [];
|
22 |
+
loaded = false;
|
23 |
+
/**
|
24 |
+
* register worker message event handlers.
|
25 |
+
*/
|
26 |
+
#registerHandlers = () => {
|
27 |
+
if (this.#worker) {
|
28 |
+
this.#worker.onmessage = ({ data: { id, type, data }, }) => {
|
29 |
+
switch (type) {
|
30 |
+
case FFMessageType.LOAD:
|
31 |
+
this.loaded = true;
|
32 |
+
this.#resolves[id](data);
|
33 |
+
break;
|
34 |
+
case FFMessageType.MOUNT:
|
35 |
+
case FFMessageType.UNMOUNT:
|
36 |
+
case FFMessageType.EXEC:
|
37 |
+
case FFMessageType.WRITE_FILE:
|
38 |
+
case FFMessageType.READ_FILE:
|
39 |
+
case FFMessageType.DELETE_FILE:
|
40 |
+
case FFMessageType.RENAME:
|
41 |
+
case FFMessageType.CREATE_DIR:
|
42 |
+
case FFMessageType.LIST_DIR:
|
43 |
+
case FFMessageType.DELETE_DIR:
|
44 |
+
this.#resolves[id](data);
|
45 |
+
break;
|
46 |
+
case FFMessageType.LOG:
|
47 |
+
this.#logEventCallbacks.forEach((f) => f(data));
|
48 |
+
break;
|
49 |
+
case FFMessageType.PROGRESS:
|
50 |
+
this.#progressEventCallbacks.forEach((f) => f(data));
|
51 |
+
break;
|
52 |
+
case FFMessageType.ERROR:
|
53 |
+
this.#rejects[id](data);
|
54 |
+
break;
|
55 |
+
}
|
56 |
+
delete this.#resolves[id];
|
57 |
+
delete this.#rejects[id];
|
58 |
+
};
|
59 |
+
}
|
60 |
+
};
|
61 |
+
/**
|
62 |
+
* Generic function to send messages to web worker.
|
63 |
+
*/
|
64 |
+
#send = ({ type, data }, trans = [], signal) => {
|
65 |
+
if (!this.#worker) {
|
66 |
+
return Promise.reject(ERROR_NOT_LOADED);
|
67 |
+
}
|
68 |
+
return new Promise((resolve, reject) => {
|
69 |
+
const id = getMessageID();
|
70 |
+
this.#worker && this.#worker.postMessage({ id, type, data }, trans);
|
71 |
+
this.#resolves[id] = resolve;
|
72 |
+
this.#rejects[id] = reject;
|
73 |
+
signal?.addEventListener("abort", () => {
|
74 |
+
reject(new DOMException(`Message # ${id} was aborted`, "AbortError"));
|
75 |
+
}, { once: true });
|
76 |
+
});
|
77 |
+
};
|
78 |
+
on(event, callback) {
|
79 |
+
if (event === "log") {
|
80 |
+
this.#logEventCallbacks.push(callback);
|
81 |
+
}
|
82 |
+
else if (event === "progress") {
|
83 |
+
this.#progressEventCallbacks.push(callback);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
off(event, callback) {
|
87 |
+
if (event === "log") {
|
88 |
+
this.#logEventCallbacks = this.#logEventCallbacks.filter((f) => f !== callback);
|
89 |
+
}
|
90 |
+
else if (event === "progress") {
|
91 |
+
this.#progressEventCallbacks = this.#progressEventCallbacks.filter((f) => f !== callback);
|
92 |
+
}
|
93 |
+
}
|
94 |
+
/**
|
95 |
+
* Loads ffmpeg-core inside web worker. It is required to call this method first
|
96 |
+
* as it initializes WebAssembly and other essential variables.
|
97 |
+
*
|
98 |
+
* @category FFmpeg
|
99 |
+
* @returns `true` if ffmpeg core is loaded for the first time.
|
100 |
+
*/
|
101 |
+
load = (config = {}, { signal } = {}) => {
|
102 |
+
if (!this.#worker) {
|
103 |
+
this.#worker = new Worker(new URL("./worker.js", import.meta.url), {
|
104 |
+
type: "module",
|
105 |
+
});
|
106 |
+
this.#registerHandlers();
|
107 |
+
}
|
108 |
+
return this.#send({
|
109 |
+
type: FFMessageType.LOAD,
|
110 |
+
data: config,
|
111 |
+
}, undefined, signal);
|
112 |
+
};
|
113 |
+
/**
|
114 |
+
* Execute ffmpeg command.
|
115 |
+
*
|
116 |
+
* @remarks
|
117 |
+
* To avoid common I/O issues, ["-nostdin", "-y"] are prepended to the args
|
118 |
+
* by default.
|
119 |
+
*
|
120 |
+
* @example
|
121 |
+
* ```ts
|
122 |
+
* const ffmpeg = new FFmpeg();
|
123 |
+
* await ffmpeg.load();
|
124 |
+
* await ffmpeg.writeFile("video.avi", ...);
|
125 |
+
* // ffmpeg -i video.avi video.mp4
|
126 |
+
* await ffmpeg.exec(["-i", "video.avi", "video.mp4"]);
|
127 |
+
* const data = ffmpeg.readFile("video.mp4");
|
128 |
+
* ```
|
129 |
+
*
|
130 |
+
* @returns `0` if no error, `!= 0` if timeout (1) or error.
|
131 |
+
* @category FFmpeg
|
132 |
+
*/
|
133 |
+
exec = (
|
134 |
+
/** ffmpeg command line args */
|
135 |
+
args,
|
136 |
+
/**
|
137 |
+
* milliseconds to wait before stopping the command execution.
|
138 |
+
*
|
139 |
+
* @defaultValue -1
|
140 |
+
*/
|
141 |
+
timeout = -1, { signal } = {}) => this.#send({
|
142 |
+
type: FFMessageType.EXEC,
|
143 |
+
data: { args, timeout },
|
144 |
+
}, undefined, signal);
|
145 |
+
/**
|
146 |
+
* Terminate all ongoing API calls and terminate web worker.
|
147 |
+
* `FFmpeg.load()` must be called again before calling any other APIs.
|
148 |
+
*
|
149 |
+
* @category FFmpeg
|
150 |
+
*/
|
151 |
+
terminate = () => {
|
152 |
+
const ids = Object.keys(this.#rejects);
|
153 |
+
// rejects all incomplete Promises.
|
154 |
+
for (const id of ids) {
|
155 |
+
this.#rejects[id](ERROR_TERMINATED);
|
156 |
+
delete this.#rejects[id];
|
157 |
+
delete this.#resolves[id];
|
158 |
+
}
|
159 |
+
if (this.#worker) {
|
160 |
+
this.#worker.terminate();
|
161 |
+
this.#worker = null;
|
162 |
+
this.loaded = false;
|
163 |
+
}
|
164 |
+
};
|
165 |
+
/**
|
166 |
+
* Write data to ffmpeg.wasm.
|
167 |
+
*
|
168 |
+
* @example
|
169 |
+
* ```ts
|
170 |
+
* const ffmpeg = new FFmpeg();
|
171 |
+
* await ffmpeg.load();
|
172 |
+
* await ffmpeg.writeFile("video.avi", await fetchFile("../video.avi"));
|
173 |
+
* await ffmpeg.writeFile("text.txt", "hello world");
|
174 |
+
* ```
|
175 |
+
*
|
176 |
+
* @category File System
|
177 |
+
*/
|
178 |
+
writeFile = (path, data, { signal } = {}) => {
|
179 |
+
const trans = [];
|
180 |
+
if (data instanceof Uint8Array) {
|
181 |
+
trans.push(data.buffer);
|
182 |
+
}
|
183 |
+
return this.#send({
|
184 |
+
type: FFMessageType.WRITE_FILE,
|
185 |
+
data: { path, data },
|
186 |
+
}, trans, signal);
|
187 |
+
};
|
188 |
+
mount = (fsType, options, mountPoint) => {
|
189 |
+
const trans = [];
|
190 |
+
return this.#send({
|
191 |
+
type: FFMessageType.MOUNT,
|
192 |
+
data: { fsType, options, mountPoint },
|
193 |
+
}, trans);
|
194 |
+
};
|
195 |
+
unmount = (mountPoint) => {
|
196 |
+
const trans = [];
|
197 |
+
return this.#send({
|
198 |
+
type: FFMessageType.UNMOUNT,
|
199 |
+
data: { mountPoint },
|
200 |
+
}, trans);
|
201 |
+
};
|
202 |
+
/**
|
203 |
+
* Read data from ffmpeg.wasm.
|
204 |
+
*
|
205 |
+
* @example
|
206 |
+
* ```ts
|
207 |
+
* const ffmpeg = new FFmpeg();
|
208 |
+
* await ffmpeg.load();
|
209 |
+
* const data = await ffmpeg.readFile("video.mp4");
|
210 |
+
* ```
|
211 |
+
*
|
212 |
+
* @category File System
|
213 |
+
*/
|
214 |
+
readFile = (path,
|
215 |
+
/**
|
216 |
+
* File content encoding, supports two encodings:
|
217 |
+
* - utf8: read file as text file, return data in string type.
|
218 |
+
* - binary: read file as binary file, return data in Uint8Array type.
|
219 |
+
*
|
220 |
+
* @defaultValue binary
|
221 |
+
*/
|
222 |
+
encoding = "binary", { signal } = {}) => this.#send({
|
223 |
+
type: FFMessageType.READ_FILE,
|
224 |
+
data: { path, encoding },
|
225 |
+
}, undefined, signal);
|
226 |
+
/**
|
227 |
+
* Delete a file.
|
228 |
+
*
|
229 |
+
* @category File System
|
230 |
+
*/
|
231 |
+
deleteFile = (path, { signal } = {}) => this.#send({
|
232 |
+
type: FFMessageType.DELETE_FILE,
|
233 |
+
data: { path },
|
234 |
+
}, undefined, signal);
|
235 |
+
/**
|
236 |
+
* Rename a file or directory.
|
237 |
+
*
|
238 |
+
* @category File System
|
239 |
+
*/
|
240 |
+
rename = (oldPath, newPath, { signal } = {}) => this.#send({
|
241 |
+
type: FFMessageType.RENAME,
|
242 |
+
data: { oldPath, newPath },
|
243 |
+
}, undefined, signal);
|
244 |
+
/**
|
245 |
+
* Create a directory.
|
246 |
+
*
|
247 |
+
* @category File System
|
248 |
+
*/
|
249 |
+
createDir = (path, { signal } = {}) => this.#send({
|
250 |
+
type: FFMessageType.CREATE_DIR,
|
251 |
+
data: { path },
|
252 |
+
}, undefined, signal);
|
253 |
+
/**
|
254 |
+
* List directory contents.
|
255 |
+
*
|
256 |
+
* @category File System
|
257 |
+
*/
|
258 |
+
listDir = (path, { signal } = {}) => this.#send({
|
259 |
+
type: FFMessageType.LIST_DIR,
|
260 |
+
data: { path },
|
261 |
+
}, undefined, signal);
|
262 |
+
/**
|
263 |
+
* Delete an empty directory.
|
264 |
+
*
|
265 |
+
* @category File System
|
266 |
+
*/
|
267 |
+
deleteDir = (path, { signal } = {}) => this.#send({
|
268 |
+
type: FFMessageType.DELETE_DIR,
|
269 |
+
data: { path },
|
270 |
+
}, undefined, signal);
|
271 |
+
}
|
assets/ffmpeg/package/dist/esm/const.d.ts
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export declare const MIME_TYPE_JAVASCRIPT = "text/javascript";
|
2 |
+
export declare const MIME_TYPE_WASM = "application/wasm";
|
3 |
+
export declare const CORE_VERSION = "0.12.1";
|
4 |
+
export declare const CORE_URL: string;
|
5 |
+
export declare enum FFMessageType {
|
6 |
+
LOAD = "LOAD",
|
7 |
+
EXEC = "EXEC",
|
8 |
+
WRITE_FILE = "WRITE_FILE",
|
9 |
+
READ_FILE = "READ_FILE",
|
10 |
+
DELETE_FILE = "DELETE_FILE",
|
11 |
+
RENAME = "RENAME",
|
12 |
+
CREATE_DIR = "CREATE_DIR",
|
13 |
+
LIST_DIR = "LIST_DIR",
|
14 |
+
DELETE_DIR = "DELETE_DIR",
|
15 |
+
ERROR = "ERROR",
|
16 |
+
DOWNLOAD = "DOWNLOAD",
|
17 |
+
PROGRESS = "PROGRESS",
|
18 |
+
LOG = "LOG",
|
19 |
+
MOUNT = "MOUNT",
|
20 |
+
UNMOUNT = "UNMOUNT"
|
21 |
+
}
|
assets/ffmpeg/package/dist/esm/const.js
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const MIME_TYPE_JAVASCRIPT = "text/javascript";
|
2 |
+
export const MIME_TYPE_WASM = "application/wasm";
|
3 |
+
export const CORE_VERSION = "0.12.1";
|
4 |
+
export const CORE_URL = `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.js`;
|
5 |
+
export var FFMessageType;
|
6 |
+
(function (FFMessageType) {
|
7 |
+
FFMessageType["LOAD"] = "LOAD";
|
8 |
+
FFMessageType["EXEC"] = "EXEC";
|
9 |
+
FFMessageType["WRITE_FILE"] = "WRITE_FILE";
|
10 |
+
FFMessageType["READ_FILE"] = "READ_FILE";
|
11 |
+
FFMessageType["DELETE_FILE"] = "DELETE_FILE";
|
12 |
+
FFMessageType["RENAME"] = "RENAME";
|
13 |
+
FFMessageType["CREATE_DIR"] = "CREATE_DIR";
|
14 |
+
FFMessageType["LIST_DIR"] = "LIST_DIR";
|
15 |
+
FFMessageType["DELETE_DIR"] = "DELETE_DIR";
|
16 |
+
FFMessageType["ERROR"] = "ERROR";
|
17 |
+
FFMessageType["DOWNLOAD"] = "DOWNLOAD";
|
18 |
+
FFMessageType["PROGRESS"] = "PROGRESS";
|
19 |
+
FFMessageType["LOG"] = "LOG";
|
20 |
+
FFMessageType["MOUNT"] = "MOUNT";
|
21 |
+
FFMessageType["UNMOUNT"] = "UNMOUNT";
|
22 |
+
})(FFMessageType || (FFMessageType = {}));
|
assets/ffmpeg/package/dist/esm/empty.d.mts
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
export declare class FFmpeg {
|
2 |
+
constructor();
|
3 |
+
}
|
assets/ffmpeg/package/dist/esm/empty.mjs
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// File to be imported in node enviroments
|
2 |
+
export class FFmpeg {
|
3 |
+
constructor() {
|
4 |
+
throw new Error("ffmpeg.wasm does not support nodejs");
|
5 |
+
}
|
6 |
+
}
|
assets/ffmpeg/package/dist/esm/errors.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export declare const ERROR_UNKNOWN_MESSAGE_TYPE: Error;
|
2 |
+
export declare const ERROR_NOT_LOADED: Error;
|
3 |
+
export declare const ERROR_TERMINATED: Error;
|
4 |
+
export declare const ERROR_IMPORT_FAILURE: Error;
|
assets/ffmpeg/package/dist/esm/errors.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export const ERROR_UNKNOWN_MESSAGE_TYPE = new Error("unknown message type");
|
2 |
+
export const ERROR_NOT_LOADED = new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first");
|
3 |
+
export const ERROR_TERMINATED = new Error("called FFmpeg.terminate()");
|
4 |
+
export const ERROR_IMPORT_FAILURE = new Error("failed to import ffmpeg-core.js");
|
assets/ffmpeg/package/dist/esm/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export * from "./classes.js";
|
assets/ffmpeg/package/dist/esm/index.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export * from "./classes.js";
|
assets/ffmpeg/package/dist/esm/types.d.ts
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export type FFFSPath = string;
|
2 |
+
/**
|
3 |
+
* ffmpeg-core loading configuration.
|
4 |
+
*/
|
5 |
+
export interface FFMessageLoadConfig {
|
6 |
+
/**
|
7 |
+
* `ffmpeg-core.js` URL.
|
8 |
+
*
|
9 |
+
* @defaultValue `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.js`;
|
10 |
+
*/
|
11 |
+
coreURL?: string;
|
12 |
+
/**
|
13 |
+
* `ffmpeg-core.wasm` URL.
|
14 |
+
*
|
15 |
+
* @defaultValue `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.wasm`;
|
16 |
+
*/
|
17 |
+
wasmURL?: string;
|
18 |
+
/**
|
19 |
+
* `ffmpeg-core.worker.js` URL.
|
20 |
+
*
|
21 |
+
* @defaultValue `https://unpkg.com/@ffmpeg/core-mt@${CORE_VERSION}/dist/umd/ffmpeg-core.worker.js`;
|
22 |
+
*/
|
23 |
+
workerURL?: string;
|
24 |
+
}
|
25 |
+
export interface FFMessageExecData {
|
26 |
+
args: string[];
|
27 |
+
timeout?: number;
|
28 |
+
}
|
29 |
+
export interface FFMessageWriteFileData {
|
30 |
+
path: FFFSPath;
|
31 |
+
data: FileData;
|
32 |
+
}
|
33 |
+
export interface FFMessageReadFileData {
|
34 |
+
path: FFFSPath;
|
35 |
+
encoding: string;
|
36 |
+
}
|
37 |
+
export interface FFMessageDeleteFileData {
|
38 |
+
path: FFFSPath;
|
39 |
+
}
|
40 |
+
export interface FFMessageRenameData {
|
41 |
+
oldPath: FFFSPath;
|
42 |
+
newPath: FFFSPath;
|
43 |
+
}
|
44 |
+
export interface FFMessageCreateDirData {
|
45 |
+
path: FFFSPath;
|
46 |
+
}
|
47 |
+
export interface FFMessageListDirData {
|
48 |
+
path: FFFSPath;
|
49 |
+
}
|
50 |
+
/**
|
51 |
+
* @remarks
|
52 |
+
* Only deletes empty directory.
|
53 |
+
*/
|
54 |
+
export interface FFMessageDeleteDirData {
|
55 |
+
path: FFFSPath;
|
56 |
+
}
|
57 |
+
export declare enum FFFSType {
|
58 |
+
MEMFS = "MEMFS",
|
59 |
+
NODEFS = "NODEFS",
|
60 |
+
NODERAWFS = "NODERAWFS",
|
61 |
+
IDBFS = "IDBFS",
|
62 |
+
WORKERFS = "WORKERFS",
|
63 |
+
PROXYFS = "PROXYFS"
|
64 |
+
}
|
65 |
+
export type WorkerFSFileEntry = File;
|
66 |
+
export interface WorkerFSBlobEntry {
|
67 |
+
name: string;
|
68 |
+
data: Blob;
|
69 |
+
}
|
70 |
+
export interface WorkerFSMountData {
|
71 |
+
blobs?: WorkerFSBlobEntry[];
|
72 |
+
files?: WorkerFSFileEntry[];
|
73 |
+
}
|
74 |
+
export type FFFSMountOptions = WorkerFSMountData;
|
75 |
+
export interface FFMessageMountData {
|
76 |
+
fsType: FFFSType;
|
77 |
+
options: FFFSMountOptions;
|
78 |
+
mountPoint: FFFSPath;
|
79 |
+
}
|
80 |
+
export interface FFMessageUnmountData {
|
81 |
+
mountPoint: FFFSPath;
|
82 |
+
}
|
83 |
+
export type FFMessageData = FFMessageLoadConfig | FFMessageExecData | FFMessageWriteFileData | FFMessageReadFileData | FFMessageDeleteFileData | FFMessageRenameData | FFMessageCreateDirData | FFMessageListDirData | FFMessageDeleteDirData | FFMessageMountData | FFMessageUnmountData;
|
84 |
+
export interface Message {
|
85 |
+
type: string;
|
86 |
+
data?: FFMessageData;
|
87 |
+
}
|
88 |
+
export interface FFMessage extends Message {
|
89 |
+
id: number;
|
90 |
+
}
|
91 |
+
export interface FFMessageEvent extends MessageEvent {
|
92 |
+
data: FFMessage;
|
93 |
+
}
|
94 |
+
export interface LogEvent {
|
95 |
+
type: string;
|
96 |
+
message: string;
|
97 |
+
}
|
98 |
+
export interface ProgressEvent {
|
99 |
+
progress: number;
|
100 |
+
time: number;
|
101 |
+
}
|
102 |
+
export type ExitCode = number;
|
103 |
+
export type ErrorMessage = string;
|
104 |
+
export type FileData = Uint8Array | string;
|
105 |
+
export type IsFirst = boolean;
|
106 |
+
export type OK = boolean;
|
107 |
+
export interface FSNode {
|
108 |
+
name: string;
|
109 |
+
isDir: boolean;
|
110 |
+
}
|
111 |
+
export type CallbackData = FileData | ExitCode | ErrorMessage | LogEvent | ProgressEvent | IsFirst | OK | Error | FSNode[] | undefined;
|
112 |
+
export interface Callbacks {
|
113 |
+
[id: number | string]: (data: CallbackData) => void;
|
114 |
+
}
|
115 |
+
export type LogEventCallback = (event: LogEvent) => void;
|
116 |
+
export type ProgressEventCallback = (event: ProgressEvent) => void;
|
117 |
+
export interface FFMessageEventCallback {
|
118 |
+
data: {
|
119 |
+
id: number;
|
120 |
+
type: string;
|
121 |
+
data: CallbackData;
|
122 |
+
};
|
123 |
+
}
|
assets/ffmpeg/package/dist/esm/types.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export var FFFSType;
|
2 |
+
(function (FFFSType) {
|
3 |
+
FFFSType["MEMFS"] = "MEMFS";
|
4 |
+
FFFSType["NODEFS"] = "NODEFS";
|
5 |
+
FFFSType["NODERAWFS"] = "NODERAWFS";
|
6 |
+
FFFSType["IDBFS"] = "IDBFS";
|
7 |
+
FFFSType["WORKERFS"] = "WORKERFS";
|
8 |
+
FFFSType["PROXYFS"] = "PROXYFS";
|
9 |
+
})(FFFSType || (FFFSType = {}));
|
assets/ffmpeg/package/dist/esm/utils.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Generate an unique message ID.
|
3 |
+
*/
|
4 |
+
export declare const getMessageID: () => number;
|
assets/ffmpeg/package/dist/esm/utils.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Generate an unique message ID.
|
3 |
+
*/
|
4 |
+
export const getMessageID = (() => {
|
5 |
+
let messageID = 0;
|
6 |
+
return () => messageID++;
|
7 |
+
})();
|
assets/ffmpeg/package/dist/esm/worker.d.ts
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/// <reference no-default-lib="true"/>
|
2 |
+
/// <reference lib="esnext" />
|
3 |
+
/// <reference lib="webworker" />
|
4 |
+
import type { FFmpegCoreModuleFactory } from "@ffmpeg/types";
|
5 |
+
declare global {
|
6 |
+
interface WorkerGlobalScope {
|
7 |
+
createFFmpegCore: FFmpegCoreModuleFactory;
|
8 |
+
}
|
9 |
+
}
|
assets/ffmpeg/package/dist/esm/worker.js
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/// <reference no-default-lib="true" />
|
2 |
+
/// <reference lib="esnext" />
|
3 |
+
/// <reference lib="webworker" />
|
4 |
+
import { CORE_URL, FFMessageType } from "./const.js";
|
5 |
+
import { ERROR_UNKNOWN_MESSAGE_TYPE, ERROR_NOT_LOADED, ERROR_IMPORT_FAILURE, } from "./errors.js";
|
6 |
+
let ffmpeg;
|
7 |
+
const load = async ({ coreURL: _coreURL = CORE_URL, wasmURL: _wasmURL, workerURL: _workerURL, }) => {
|
8 |
+
const first = !ffmpeg;
|
9 |
+
const coreURL = _coreURL;
|
10 |
+
const wasmURL = _wasmURL ? _wasmURL : _coreURL.replace(/.js$/g, ".wasm");
|
11 |
+
const workerURL = _workerURL
|
12 |
+
? _workerURL
|
13 |
+
: _coreURL.replace(/.js$/g, ".worker.js");
|
14 |
+
try {
|
15 |
+
// when web worker type is `classic`.
|
16 |
+
importScripts(coreURL);
|
17 |
+
}
|
18 |
+
catch {
|
19 |
+
// when web worker type is `module`.
|
20 |
+
self.createFFmpegCore = (await import(
|
21 |
+
/* @vite-ignore */ coreURL)).default;
|
22 |
+
if (!self.createFFmpegCore) {
|
23 |
+
throw ERROR_IMPORT_FAILURE;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
ffmpeg = await self.createFFmpegCore({
|
27 |
+
// Fix `Overload resolution failed.` when using multi-threaded ffmpeg-core.
|
28 |
+
// Encoded wasmURL and workerURL in the URL as a hack to fix locateFile issue.
|
29 |
+
mainScriptUrlOrBlob: `${coreURL}#${btoa(JSON.stringify({ wasmURL, workerURL }))}`,
|
30 |
+
});
|
31 |
+
ffmpeg.setLogger((data) => self.postMessage({ type: FFMessageType.LOG, data }));
|
32 |
+
ffmpeg.setProgress((data) => self.postMessage({
|
33 |
+
type: FFMessageType.PROGRESS,
|
34 |
+
data,
|
35 |
+
}));
|
36 |
+
return first;
|
37 |
+
};
|
38 |
+
const exec = ({ args, timeout = -1 }) => {
|
39 |
+
ffmpeg.setTimeout(timeout);
|
40 |
+
ffmpeg.exec(...args);
|
41 |
+
const ret = ffmpeg.ret;
|
42 |
+
ffmpeg.reset();
|
43 |
+
return ret;
|
44 |
+
};
|
45 |
+
const writeFile = ({ path, data }) => {
|
46 |
+
ffmpeg.FS.writeFile(path, data);
|
47 |
+
return true;
|
48 |
+
};
|
49 |
+
const readFile = ({ path, encoding }) => ffmpeg.FS.readFile(path, { encoding });
|
50 |
+
// TODO: check if deletion works.
|
51 |
+
const deleteFile = ({ path }) => {
|
52 |
+
ffmpeg.FS.unlink(path);
|
53 |
+
return true;
|
54 |
+
};
|
55 |
+
const rename = ({ oldPath, newPath }) => {
|
56 |
+
ffmpeg.FS.rename(oldPath, newPath);
|
57 |
+
return true;
|
58 |
+
};
|
59 |
+
// TODO: check if creation works.
|
60 |
+
const createDir = ({ path }) => {
|
61 |
+
ffmpeg.FS.mkdir(path);
|
62 |
+
return true;
|
63 |
+
};
|
64 |
+
const listDir = ({ path }) => {
|
65 |
+
const names = ffmpeg.FS.readdir(path);
|
66 |
+
const nodes = [];
|
67 |
+
for (const name of names) {
|
68 |
+
const stat = ffmpeg.FS.stat(`${path}/${name}`);
|
69 |
+
const isDir = ffmpeg.FS.isDir(stat.mode);
|
70 |
+
nodes.push({ name, isDir });
|
71 |
+
}
|
72 |
+
return nodes;
|
73 |
+
};
|
74 |
+
// TODO: check if deletion works.
|
75 |
+
const deleteDir = ({ path }) => {
|
76 |
+
ffmpeg.FS.rmdir(path);
|
77 |
+
return true;
|
78 |
+
};
|
79 |
+
const mount = ({ fsType, options, mountPoint }) => {
|
80 |
+
let str = fsType;
|
81 |
+
let fs = ffmpeg.FS.filesystems[str];
|
82 |
+
if (!fs)
|
83 |
+
return false;
|
84 |
+
ffmpeg.FS.mount(fs, options, mountPoint);
|
85 |
+
return true;
|
86 |
+
};
|
87 |
+
const unmount = ({ mountPoint }) => {
|
88 |
+
ffmpeg.FS.unmount(mountPoint);
|
89 |
+
return true;
|
90 |
+
};
|
91 |
+
self.onmessage = async ({ data: { id, type, data: _data }, }) => {
|
92 |
+
const trans = [];
|
93 |
+
let data;
|
94 |
+
try {
|
95 |
+
if (type !== FFMessageType.LOAD && !ffmpeg)
|
96 |
+
throw ERROR_NOT_LOADED;
|
97 |
+
switch (type) {
|
98 |
+
case FFMessageType.LOAD:
|
99 |
+
data = await load(_data);
|
100 |
+
break;
|
101 |
+
case FFMessageType.EXEC:
|
102 |
+
data = exec(_data);
|
103 |
+
break;
|
104 |
+
case FFMessageType.WRITE_FILE:
|
105 |
+
data = writeFile(_data);
|
106 |
+
break;
|
107 |
+
case FFMessageType.READ_FILE:
|
108 |
+
data = readFile(_data);
|
109 |
+
break;
|
110 |
+
case FFMessageType.DELETE_FILE:
|
111 |
+
data = deleteFile(_data);
|
112 |
+
break;
|
113 |
+
case FFMessageType.RENAME:
|
114 |
+
data = rename(_data);
|
115 |
+
break;
|
116 |
+
case FFMessageType.CREATE_DIR:
|
117 |
+
data = createDir(_data);
|
118 |
+
break;
|
119 |
+
case FFMessageType.LIST_DIR:
|
120 |
+
data = listDir(_data);
|
121 |
+
break;
|
122 |
+
case FFMessageType.DELETE_DIR:
|
123 |
+
data = deleteDir(_data);
|
124 |
+
break;
|
125 |
+
case FFMessageType.MOUNT:
|
126 |
+
data = mount(_data);
|
127 |
+
break;
|
128 |
+
case FFMessageType.UNMOUNT:
|
129 |
+
data = unmount(_data);
|
130 |
+
break;
|
131 |
+
default:
|
132 |
+
throw ERROR_UNKNOWN_MESSAGE_TYPE;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
catch (e) {
|
136 |
+
self.postMessage({
|
137 |
+
id,
|
138 |
+
type: FFMessageType.ERROR,
|
139 |
+
data: e.toString(),
|
140 |
+
});
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
if (data instanceof Uint8Array) {
|
144 |
+
trans.push(data.buffer);
|
145 |
+
}
|
146 |
+
self.postMessage({ id, type, data }, trans);
|
147 |
+
};
|
assets/ffmpeg/package/dist/umd/814.ffmpeg.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FFmpegWASM=t():e.FFmpegWASM=t()}(self,(()=>(()=>{var e={454:e=>{function t(e){return Promise.resolve().then((()=>{var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}))}t.keys=()=>[],t.resolve=t,t.id=454,e.exports=t}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var s=t[a]={exports:{}};return e[a](s,s.exports,r),s.exports}return r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e;!function(e){e.LOAD="LOAD",e.EXEC="EXEC",e.WRITE_FILE="WRITE_FILE",e.READ_FILE="READ_FILE",e.DELETE_FILE="DELETE_FILE",e.RENAME="RENAME",e.CREATE_DIR="CREATE_DIR",e.LIST_DIR="LIST_DIR",e.DELETE_DIR="DELETE_DIR",e.ERROR="ERROR",e.DOWNLOAD="DOWNLOAD",e.PROGRESS="PROGRESS",e.LOG="LOG",e.MOUNT="MOUNT",e.UNMOUNT="UNMOUNT"}(e||(e={}));const t=new Error("unknown message type"),a=new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),o=(new Error("called FFmpeg.terminate()"),new Error("failed to import ffmpeg-core.js"));let s;self.onmessage=async({data:{id:n,type:E,data:i}})=>{const c=[];let p;try{if(E!==e.LOAD&&!s)throw a;switch(E){case e.LOAD:p=await(async({coreURL:t="https://unpkg.com/@ffmpeg/[email protected]/dist/umd/ffmpeg-core.js",wasmURL:a,workerURL:n})=>{const E=!s,i=t,c=a||t.replace(/.js$/g,".wasm"),p=n||t.replace(/.js$/g,".worker.js");try{importScripts(i)}catch{if(self.createFFmpegCore=(await r(454)(i)).default,!self.createFFmpegCore)throw o}return s=await self.createFFmpegCore({mainScriptUrlOrBlob:`${i}#${btoa(JSON.stringify({wasmURL:c,workerURL:p}))}`}),s.setLogger((t=>self.postMessage({type:e.LOG,data:t}))),s.setProgress((t=>self.postMessage({type:e.PROGRESS,data:t}))),E})(i);break;case e.EXEC:p=(({args:e,timeout:t=-1})=>{s.setTimeout(t),s.exec(...e);const r=s.ret;return s.reset(),r})(i);break;case e.WRITE_FILE:p=(({path:e,data:t})=>(s.FS.writeFile(e,t),!0))(i);break;case e.READ_FILE:p=(({path:e,encoding:t})=>s.FS.readFile(e,{encoding:t}))(i);break;case e.DELETE_FILE:p=(({path:e})=>(s.FS.unlink(e),!0))(i);break;case e.RENAME:p=(({oldPath:e,newPath:t})=>(s.FS.rename(e,t),!0))(i);break;case e.CREATE_DIR:p=(({path:e})=>(s.FS.mkdir(e),!0))(i);break;case e.LIST_DIR:p=(({path:e})=>{const t=s.FS.readdir(e),r=[];for(const a of t){const t=s.FS.stat(`${e}/${a}`),o=s.FS.isDir(t.mode);r.push({name:a,isDir:o})}return r})(i);break;case e.DELETE_DIR:p=(({path:e})=>(s.FS.rmdir(e),!0))(i);break;case e.MOUNT:p=(({fsType:e,options:t,mountPoint:r})=>{let a=e,o=s.FS.filesystems[a];return!!o&&(s.FS.mount(o,t,r),!0)})(i);break;case e.UNMOUNT:p=(({mountPoint:e})=>(s.FS.unmount(e),!0))(i);break;default:throw t}}catch(t){return void self.postMessage({id:n,type:e.ERROR,data:t.toString()})}p instanceof Uint8Array&&c.push(p.buffer),self.postMessage({id:n,type:E,data:p},c)}})(),{}})()));
|
2 |
+
//# sourceMappingURL=814.ffmpeg.js.map
|
assets/ffmpeg/package/dist/umd/814.ffmpeg.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"814.ffmpeg.js","mappings":"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","sources":["webpack://FFmpegWASM/webpack/universalModuleDefinition","webpack://FFmpegWASM/./dist/esm/ lazy namespace object","webpack://FFmpegWASM/webpack/bootstrap","webpack://FFmpegWASM/webpack/runtime/hasOwnProperty shorthand","webpack://FFmpegWASM/./dist/esm/const.js","webpack://FFmpegWASM/./dist/esm/errors.js","webpack://FFmpegWASM/./dist/esm/worker.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FFmpegWASM\"] = factory();\n\telse\n\t\troot[\"FFmpegWASM\"] = factory();\n})(self, () => {\nreturn ","function webpackEmptyAsyncContext(req) {\n\t// Here Promise.resolve().then() is used instead of new Promise() to prevent\n\t// uncaught exception popping up in devtools\n\treturn Promise.resolve().then(() => {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t});\n}\nwebpackEmptyAsyncContext.keys = () => ([]);\nwebpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;\nwebpackEmptyAsyncContext.id = 454;\nmodule.exports = webpackEmptyAsyncContext;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","export const MIME_TYPE_JAVASCRIPT = \"text/javascript\";\nexport const MIME_TYPE_WASM = \"application/wasm\";\nexport const CORE_VERSION = \"0.12.1\";\nexport const CORE_URL = `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.js`;\nexport var FFMessageType;\n(function (FFMessageType) {\n FFMessageType[\"LOAD\"] = \"LOAD\";\n FFMessageType[\"EXEC\"] = \"EXEC\";\n FFMessageType[\"WRITE_FILE\"] = \"WRITE_FILE\";\n FFMessageType[\"READ_FILE\"] = \"READ_FILE\";\n FFMessageType[\"DELETE_FILE\"] = \"DELETE_FILE\";\n FFMessageType[\"RENAME\"] = \"RENAME\";\n FFMessageType[\"CREATE_DIR\"] = \"CREATE_DIR\";\n FFMessageType[\"LIST_DIR\"] = \"LIST_DIR\";\n FFMessageType[\"DELETE_DIR\"] = \"DELETE_DIR\";\n FFMessageType[\"ERROR\"] = \"ERROR\";\n FFMessageType[\"DOWNLOAD\"] = \"DOWNLOAD\";\n FFMessageType[\"PROGRESS\"] = \"PROGRESS\";\n FFMessageType[\"LOG\"] = \"LOG\";\n FFMessageType[\"MOUNT\"] = \"MOUNT\";\n FFMessageType[\"UNMOUNT\"] = \"UNMOUNT\";\n})(FFMessageType || (FFMessageType = {}));\n","export const ERROR_UNKNOWN_MESSAGE_TYPE = new Error(\"unknown message type\");\nexport const ERROR_NOT_LOADED = new Error(\"ffmpeg is not loaded, call `await ffmpeg.load()` first\");\nexport const ERROR_TERMINATED = new Error(\"called FFmpeg.terminate()\");\nexport const ERROR_IMPORT_FAILURE = new Error(\"failed to import ffmpeg-core.js\");\n","/// <reference no-default-lib=\"true\" />\n/// <reference lib=\"esnext\" />\n/// <reference lib=\"webworker\" />\nimport { CORE_URL, FFMessageType } from \"./const.js\";\nimport { ERROR_UNKNOWN_MESSAGE_TYPE, ERROR_NOT_LOADED, ERROR_IMPORT_FAILURE, } from \"./errors.js\";\nlet ffmpeg;\nconst load = async ({ coreURL: _coreURL = CORE_URL, wasmURL: _wasmURL, workerURL: _workerURL, }) => {\n const first = !ffmpeg;\n const coreURL = _coreURL;\n const wasmURL = _wasmURL ? _wasmURL : _coreURL.replace(/.js$/g, \".wasm\");\n const workerURL = _workerURL\n ? _workerURL\n : _coreURL.replace(/.js$/g, \".worker.js\");\n try {\n // when web worker type is `classic`.\n importScripts(coreURL);\n }\n catch {\n // when web worker type is `module`.\n self.createFFmpegCore = (await import(\n /* @vite-ignore */ coreURL)).default;\n if (!self.createFFmpegCore) {\n throw ERROR_IMPORT_FAILURE;\n }\n }\n ffmpeg = await self.createFFmpegCore({\n // Fix `Overload resolution failed.` when using multi-threaded ffmpeg-core.\n // Encoded wasmURL and workerURL in the URL as a hack to fix locateFile issue.\n mainScriptUrlOrBlob: `${coreURL}#${btoa(JSON.stringify({ wasmURL, workerURL }))}`,\n });\n ffmpeg.setLogger((data) => self.postMessage({ type: FFMessageType.LOG, data }));\n ffmpeg.setProgress((data) => self.postMessage({\n type: FFMessageType.PROGRESS,\n data,\n }));\n return first;\n};\nconst exec = ({ args, timeout = -1 }) => {\n ffmpeg.setTimeout(timeout);\n ffmpeg.exec(...args);\n const ret = ffmpeg.ret;\n ffmpeg.reset();\n return ret;\n};\nconst writeFile = ({ path, data }) => {\n ffmpeg.FS.writeFile(path, data);\n return true;\n};\nconst readFile = ({ path, encoding }) => ffmpeg.FS.readFile(path, { encoding });\n// TODO: check if deletion works.\nconst deleteFile = ({ path }) => {\n ffmpeg.FS.unlink(path);\n return true;\n};\nconst rename = ({ oldPath, newPath }) => {\n ffmpeg.FS.rename(oldPath, newPath);\n return true;\n};\n// TODO: check if creation works.\nconst createDir = ({ path }) => {\n ffmpeg.FS.mkdir(path);\n return true;\n};\nconst listDir = ({ path }) => {\n const names = ffmpeg.FS.readdir(path);\n const nodes = [];\n for (const name of names) {\n const stat = ffmpeg.FS.stat(`${path}/${name}`);\n const isDir = ffmpeg.FS.isDir(stat.mode);\n nodes.push({ name, isDir });\n }\n return nodes;\n};\n// TODO: check if deletion works.\nconst deleteDir = ({ path }) => {\n ffmpeg.FS.rmdir(path);\n return true;\n};\nconst mount = ({ fsType, options, mountPoint }) => {\n let str = fsType;\n let fs = ffmpeg.FS.filesystems[str];\n if (!fs)\n return false;\n ffmpeg.FS.mount(fs, options, mountPoint);\n return true;\n};\nconst unmount = ({ mountPoint }) => {\n ffmpeg.FS.unmount(mountPoint);\n return true;\n};\nself.onmessage = async ({ data: { id, type, data: _data }, }) => {\n const trans = [];\n let data;\n try {\n if (type !== FFMessageType.LOAD && !ffmpeg)\n throw ERROR_NOT_LOADED;\n switch (type) {\n case FFMessageType.LOAD:\n data = await load(_data);\n break;\n case FFMessageType.EXEC:\n data = exec(_data);\n break;\n case FFMessageType.WRITE_FILE:\n data = writeFile(_data);\n break;\n case FFMessageType.READ_FILE:\n data = readFile(_data);\n break;\n case FFMessageType.DELETE_FILE:\n data = deleteFile(_data);\n break;\n case FFMessageType.RENAME:\n data = rename(_data);\n break;\n case FFMessageType.CREATE_DIR:\n data = createDir(_data);\n break;\n case FFMessageType.LIST_DIR:\n data = listDir(_data);\n break;\n case FFMessageType.DELETE_DIR:\n data = deleteDir(_data);\n break;\n case FFMessageType.MOUNT:\n data = mount(_data);\n break;\n case FFMessageType.UNMOUNT:\n data = unmount(_data);\n break;\n default:\n throw ERROR_UNKNOWN_MESSAGE_TYPE;\n }\n }\n catch (e) {\n self.postMessage({\n id,\n type: FFMessageType.ERROR,\n data: e.toString(),\n });\n return;\n }\n if (data instanceof Uint8Array) {\n trans.push(data.buffer);\n }\n self.postMessage({ id, type, data }, trans);\n};\n"],"names":["root","factory","exports","module","define","amd","self","webpackEmptyAsyncContext","req","Promise","resolve","then","e","Error","code","keys","id","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","o","obj","prop","Object","prototype","hasOwnProperty","call","FFMessageType","ERROR_UNKNOWN_MESSAGE_TYPE","ERROR_NOT_LOADED","ERROR_IMPORT_FAILURE","ffmpeg","onmessage","async","data","type","_data","trans","LOAD","coreURL","_coreURL","wasmURL","_wasmURL","workerURL","_workerURL","first","replace","importScripts","createFFmpegCore","default","mainScriptUrlOrBlob","btoa","JSON","stringify","setLogger","postMessage","LOG","setProgress","PROGRESS","load","EXEC","args","timeout","setTimeout","exec","ret","reset","WRITE_FILE","path","FS","writeFile","READ_FILE","encoding","readFile","DELETE_FILE","unlink","deleteFile","RENAME","oldPath","newPath","rename","CREATE_DIR","mkdir","createDir","LIST_DIR","names","readdir","nodes","name","stat","isDir","mode","push","listDir","DELETE_DIR","rmdir","deleteDir","MOUNT","fsType","options","mountPoint","str","fs","filesystems","mount","UNMOUNT","unmount","ERROR","toString","Uint8Array","buffer"],"sourceRoot":""}
|
assets/ffmpeg/package/dist/umd/ffmpeg.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FFmpegWASM=t():e.FFmpegWASM=t()}(self,(()=>(()=>{"use strict";var e={m:{},d:(t,s)=>{for(var r in s)e.o(s,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:s[r]})},u:e=>e+".ffmpeg.js"};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var s=e.g.document;if(!t&&s&&(s.currentScript&&(t=s.currentScript.src),!t)){var r=s.getElementsByTagName("script");if(r.length)for(var a=r.length-1;a>-1&&!t;)t=r[a--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})(),e.b=document.baseURI||self.location.href;var t,s={};e.r(s),e.d(s,{FFmpeg:()=>i}),function(e){e.LOAD="LOAD",e.EXEC="EXEC",e.WRITE_FILE="WRITE_FILE",e.READ_FILE="READ_FILE",e.DELETE_FILE="DELETE_FILE",e.RENAME="RENAME",e.CREATE_DIR="CREATE_DIR",e.LIST_DIR="LIST_DIR",e.DELETE_DIR="DELETE_DIR",e.ERROR="ERROR",e.DOWNLOAD="DOWNLOAD",e.PROGRESS="PROGRESS",e.LOG="LOG",e.MOUNT="MOUNT",e.UNMOUNT="UNMOUNT"}(t||(t={}));const r=(()=>{let e=0;return()=>e++})(),a=(new Error("unknown message type"),new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first")),o=new Error("called FFmpeg.terminate()");new Error("failed to import ffmpeg-core.js");class i{#e=null;#t={};#s={};#r=[];#a=[];loaded=!1;#o=()=>{this.#e&&(this.#e.onmessage=({data:{id:e,type:s,data:r}})=>{switch(s){case t.LOAD:this.loaded=!0,this.#t[e](r);break;case t.MOUNT:case t.UNMOUNT:case t.EXEC:case t.WRITE_FILE:case t.READ_FILE:case t.DELETE_FILE:case t.RENAME:case t.CREATE_DIR:case t.LIST_DIR:case t.DELETE_DIR:this.#t[e](r);break;case t.LOG:this.#r.forEach((e=>e(r)));break;case t.PROGRESS:this.#a.forEach((e=>e(r)));break;case t.ERROR:this.#s[e](r)}delete this.#t[e],delete this.#s[e]})};#i=({type:e,data:t},s=[],o)=>this.#e?new Promise(((a,i)=>{const n=r();this.#e&&this.#e.postMessage({id:n,type:e,data:t},s),this.#t[n]=a,this.#s[n]=i,o?.addEventListener("abort",(()=>{i(new DOMException(`Message # ${n} was aborted`,"AbortError"))}),{once:!0})})):Promise.reject(a);on(e,t){"log"===e?this.#r.push(t):"progress"===e&&this.#a.push(t)}off(e,t){"log"===e?this.#r=this.#r.filter((e=>e!==t)):"progress"===e&&(this.#a=this.#a.filter((e=>e!==t)))}load=(s={},{signal:r}={})=>(this.#e||(this.#e=new Worker(new URL(e.p+e.u(814),e.b),{type:void 0}),this.#o()),this.#i({type:t.LOAD,data:s},void 0,r));exec=(e,s=-1,{signal:r}={})=>this.#i({type:t.EXEC,data:{args:e,timeout:s}},void 0,r);terminate=()=>{const e=Object.keys(this.#s);for(const t of e)this.#s[t](o),delete this.#s[t],delete this.#t[t];this.#e&&(this.#e.terminate(),this.#e=null,this.loaded=!1)};writeFile=(e,s,{signal:r}={})=>{const a=[];return s instanceof Uint8Array&&a.push(s.buffer),this.#i({type:t.WRITE_FILE,data:{path:e,data:s}},a,r)};mount=(e,s,r)=>this.#i({type:t.MOUNT,data:{fsType:e,options:s,mountPoint:r}},[]);unmount=e=>this.#i({type:t.UNMOUNT,data:{mountPoint:e}},[]);readFile=(e,s="binary",{signal:r}={})=>this.#i({type:t.READ_FILE,data:{path:e,encoding:s}},void 0,r);deleteFile=(e,{signal:s}={})=>this.#i({type:t.DELETE_FILE,data:{path:e}},void 0,s);rename=(e,s,{signal:r}={})=>this.#i({type:t.RENAME,data:{oldPath:e,newPath:s}},void 0,r);createDir=(e,{signal:s}={})=>this.#i({type:t.CREATE_DIR,data:{path:e}},void 0,s);listDir=(e,{signal:s}={})=>this.#i({type:t.LIST_DIR,data:{path:e}},void 0,s);deleteDir=(e,{signal:s}={})=>this.#i({type:t.DELETE_DIR,data:{path:e}},void 0,s)}return s})()));
|
2 |
+
//# sourceMappingURL=ffmpeg.js.map
|
assets/ffmpeg/package/dist/umd/ffmpeg.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"file":"ffmpeg.js","mappings":"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","sources":["webpack://FFmpegWASM/webpack/universalModuleDefinition","webpack://FFmpegWASM/webpack/bootstrap","webpack://FFmpegWASM/webpack/runtime/define property getters","webpack://FFmpegWASM/webpack/runtime/get javascript chunk filename","webpack://FFmpegWASM/webpack/runtime/global","webpack://FFmpegWASM/webpack/runtime/hasOwnProperty shorthand","webpack://FFmpegWASM/webpack/runtime/make namespace object","webpack://FFmpegWASM/webpack/runtime/publicPath","webpack://FFmpegWASM/webpack/runtime/jsonp chunk loading","webpack://FFmpegWASM/./dist/esm/const.js","webpack://FFmpegWASM/./dist/esm/utils.js","webpack://FFmpegWASM/./dist/esm/errors.js","webpack://FFmpegWASM/./dist/esm/classes.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FFmpegWASM\"] = factory();\n\telse\n\t\troot[\"FFmpegWASM\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","// This function allow to reference async chunks\n__webpack_require__.u = (chunkId) => {\n\t// return url for filenames based on template\n\treturn \"\" + chunkId + \".ffmpeg.js\";\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src;\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) {\n\t\t\tvar i = scripts.length - 1;\n\t\t\twhile (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;\n\t\t}\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","__webpack_require__.b = document.baseURI || self.location.href;\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t179: 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n// no on chunks loaded\n\n// no jsonp function","export const MIME_TYPE_JAVASCRIPT = \"text/javascript\";\nexport const MIME_TYPE_WASM = \"application/wasm\";\nexport const CORE_VERSION = \"0.12.1\";\nexport const CORE_URL = `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.js`;\nexport var FFMessageType;\n(function (FFMessageType) {\n FFMessageType[\"LOAD\"] = \"LOAD\";\n FFMessageType[\"EXEC\"] = \"EXEC\";\n FFMessageType[\"WRITE_FILE\"] = \"WRITE_FILE\";\n FFMessageType[\"READ_FILE\"] = \"READ_FILE\";\n FFMessageType[\"DELETE_FILE\"] = \"DELETE_FILE\";\n FFMessageType[\"RENAME\"] = \"RENAME\";\n FFMessageType[\"CREATE_DIR\"] = \"CREATE_DIR\";\n FFMessageType[\"LIST_DIR\"] = \"LIST_DIR\";\n FFMessageType[\"DELETE_DIR\"] = \"DELETE_DIR\";\n FFMessageType[\"ERROR\"] = \"ERROR\";\n FFMessageType[\"DOWNLOAD\"] = \"DOWNLOAD\";\n FFMessageType[\"PROGRESS\"] = \"PROGRESS\";\n FFMessageType[\"LOG\"] = \"LOG\";\n FFMessageType[\"MOUNT\"] = \"MOUNT\";\n FFMessageType[\"UNMOUNT\"] = \"UNMOUNT\";\n})(FFMessageType || (FFMessageType = {}));\n","/**\n * Generate an unique message ID.\n */\nexport const getMessageID = (() => {\n let messageID = 0;\n return () => messageID++;\n})();\n","export const ERROR_UNKNOWN_MESSAGE_TYPE = new Error(\"unknown message type\");\nexport const ERROR_NOT_LOADED = new Error(\"ffmpeg is not loaded, call `await ffmpeg.load()` first\");\nexport const ERROR_TERMINATED = new Error(\"called FFmpeg.terminate()\");\nexport const ERROR_IMPORT_FAILURE = new Error(\"failed to import ffmpeg-core.js\");\n","import { FFMessageType } from \"./const.js\";\nimport { getMessageID } from \"./utils.js\";\nimport { ERROR_TERMINATED, ERROR_NOT_LOADED } from \"./errors.js\";\n/**\n * Provides APIs to interact with ffmpeg web worker.\n *\n * @example\n * ```ts\n * const ffmpeg = new FFmpeg();\n * ```\n */\nexport class FFmpeg {\n #worker = null;\n /**\n * #resolves and #rejects tracks Promise resolves and rejects to\n * be called when we receive message from web worker.\n */\n #resolves = {};\n #rejects = {};\n #logEventCallbacks = [];\n #progressEventCallbacks = [];\n loaded = false;\n /**\n * register worker message event handlers.\n */\n #registerHandlers = () => {\n if (this.#worker) {\n this.#worker.onmessage = ({ data: { id, type, data }, }) => {\n switch (type) {\n case FFMessageType.LOAD:\n this.loaded = true;\n this.#resolves[id](data);\n break;\n case FFMessageType.MOUNT:\n case FFMessageType.UNMOUNT:\n case FFMessageType.EXEC:\n case FFMessageType.WRITE_FILE:\n case FFMessageType.READ_FILE:\n case FFMessageType.DELETE_FILE:\n case FFMessageType.RENAME:\n case FFMessageType.CREATE_DIR:\n case FFMessageType.LIST_DIR:\n case FFMessageType.DELETE_DIR:\n this.#resolves[id](data);\n break;\n case FFMessageType.LOG:\n this.#logEventCallbacks.forEach((f) => f(data));\n break;\n case FFMessageType.PROGRESS:\n this.#progressEventCallbacks.forEach((f) => f(data));\n break;\n case FFMessageType.ERROR:\n this.#rejects[id](data);\n break;\n }\n delete this.#resolves[id];\n delete this.#rejects[id];\n };\n }\n };\n /**\n * Generic function to send messages to web worker.\n */\n #send = ({ type, data }, trans = [], signal) => {\n if (!this.#worker) {\n return Promise.reject(ERROR_NOT_LOADED);\n }\n return new Promise((resolve, reject) => {\n const id = getMessageID();\n this.#worker && this.#worker.postMessage({ id, type, data }, trans);\n this.#resolves[id] = resolve;\n this.#rejects[id] = reject;\n signal?.addEventListener(\"abort\", () => {\n reject(new DOMException(`Message # ${id} was aborted`, \"AbortError\"));\n }, { once: true });\n });\n };\n on(event, callback) {\n if (event === \"log\") {\n this.#logEventCallbacks.push(callback);\n }\n else if (event === \"progress\") {\n this.#progressEventCallbacks.push(callback);\n }\n }\n off(event, callback) {\n if (event === \"log\") {\n this.#logEventCallbacks = this.#logEventCallbacks.filter((f) => f !== callback);\n }\n else if (event === \"progress\") {\n this.#progressEventCallbacks = this.#progressEventCallbacks.filter((f) => f !== callback);\n }\n }\n /**\n * Loads ffmpeg-core inside web worker. It is required to call this method first\n * as it initializes WebAssembly and other essential variables.\n *\n * @category FFmpeg\n * @returns `true` if ffmpeg core is loaded for the first time.\n */\n load = (config = {}, { signal } = {}) => {\n if (!this.#worker) {\n this.#worker = new Worker(new URL(\"./worker.js\", import.meta.url), {\n type: \"module\",\n });\n this.#registerHandlers();\n }\n return this.#send({\n type: FFMessageType.LOAD,\n data: config,\n }, undefined, signal);\n };\n /**\n * Execute ffmpeg command.\n *\n * @remarks\n * To avoid common I/O issues, [\"-nostdin\", \"-y\"] are prepended to the args\n * by default.\n *\n * @example\n * ```ts\n * const ffmpeg = new FFmpeg();\n * await ffmpeg.load();\n * await ffmpeg.writeFile(\"video.avi\", ...);\n * // ffmpeg -i video.avi video.mp4\n * await ffmpeg.exec([\"-i\", \"video.avi\", \"video.mp4\"]);\n * const data = ffmpeg.readFile(\"video.mp4\");\n * ```\n *\n * @returns `0` if no error, `!= 0` if timeout (1) or error.\n * @category FFmpeg\n */\n exec = (\n /** ffmpeg command line args */\n args, \n /**\n * milliseconds to wait before stopping the command execution.\n *\n * @defaultValue -1\n */\n timeout = -1, { signal } = {}) => this.#send({\n type: FFMessageType.EXEC,\n data: { args, timeout },\n }, undefined, signal);\n /**\n * Terminate all ongoing API calls and terminate web worker.\n * `FFmpeg.load()` must be called again before calling any other APIs.\n *\n * @category FFmpeg\n */\n terminate = () => {\n const ids = Object.keys(this.#rejects);\n // rejects all incomplete Promises.\n for (const id of ids) {\n this.#rejects[id](ERROR_TERMINATED);\n delete this.#rejects[id];\n delete this.#resolves[id];\n }\n if (this.#worker) {\n this.#worker.terminate();\n this.#worker = null;\n this.loaded = false;\n }\n };\n /**\n * Write data to ffmpeg.wasm.\n *\n * @example\n * ```ts\n * const ffmpeg = new FFmpeg();\n * await ffmpeg.load();\n * await ffmpeg.writeFile(\"video.avi\", await fetchFile(\"../video.avi\"));\n * await ffmpeg.writeFile(\"text.txt\", \"hello world\");\n * ```\n *\n * @category File System\n */\n writeFile = (path, data, { signal } = {}) => {\n const trans = [];\n if (data instanceof Uint8Array) {\n trans.push(data.buffer);\n }\n return this.#send({\n type: FFMessageType.WRITE_FILE,\n data: { path, data },\n }, trans, signal);\n };\n mount = (fsType, options, mountPoint) => {\n const trans = [];\n return this.#send({\n type: FFMessageType.MOUNT,\n data: { fsType, options, mountPoint },\n }, trans);\n };\n unmount = (mountPoint) => {\n const trans = [];\n return this.#send({\n type: FFMessageType.UNMOUNT,\n data: { mountPoint },\n }, trans);\n };\n /**\n * Read data from ffmpeg.wasm.\n *\n * @example\n * ```ts\n * const ffmpeg = new FFmpeg();\n * await ffmpeg.load();\n * const data = await ffmpeg.readFile(\"video.mp4\");\n * ```\n *\n * @category File System\n */\n readFile = (path, \n /**\n * File content encoding, supports two encodings:\n * - utf8: read file as text file, return data in string type.\n * - binary: read file as binary file, return data in Uint8Array type.\n *\n * @defaultValue binary\n */\n encoding = \"binary\", { signal } = {}) => this.#send({\n type: FFMessageType.READ_FILE,\n data: { path, encoding },\n }, undefined, signal);\n /**\n * Delete a file.\n *\n * @category File System\n */\n deleteFile = (path, { signal } = {}) => this.#send({\n type: FFMessageType.DELETE_FILE,\n data: { path },\n }, undefined, signal);\n /**\n * Rename a file or directory.\n *\n * @category File System\n */\n rename = (oldPath, newPath, { signal } = {}) => this.#send({\n type: FFMessageType.RENAME,\n data: { oldPath, newPath },\n }, undefined, signal);\n /**\n * Create a directory.\n *\n * @category File System\n */\n createDir = (path, { signal } = {}) => this.#send({\n type: FFMessageType.CREATE_DIR,\n data: { path },\n }, undefined, signal);\n /**\n * List directory contents.\n *\n * @category File System\n */\n listDir = (path, { signal } = {}) => this.#send({\n type: FFMessageType.LIST_DIR,\n data: { path },\n }, undefined, signal);\n /**\n * Delete an empty directory.\n *\n * @category File System\n */\n deleteDir = (path, { signal } = {}) => this.#send({\n type: FFMessageType.DELETE_DIR,\n data: { path },\n }, undefined, signal);\n}\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","chunkId","g","globalThis","this","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","scriptUrl","importScripts","location","document","currentScript","src","scripts","getElementsByTagName","length","i","Error","replace","p","b","baseURI","href","FFMessageType","getMessageID","messageID","ERROR_NOT_LOADED","ERROR_TERMINATED","FFmpeg","loaded","onmessage","data","id","type","LOAD","MOUNT","UNMOUNT","EXEC","WRITE_FILE","READ_FILE","DELETE_FILE","RENAME","CREATE_DIR","LIST_DIR","DELETE_DIR","LOG","forEach","f","PROGRESS","ERROR","trans","signal","Promise","resolve","reject","postMessage","addEventListener","DOMException","once","on","event","callback","push","off","filter","load","config","Worker","URL","undefined","exec","args","timeout","terminate","ids","keys","writeFile","path","Uint8Array","buffer","mount","fsType","options","mountPoint","unmount","readFile","encoding","deleteFile","rename","oldPath","newPath","createDir","listDir","deleteDir"],"sourceRoot":""}
|
assets/ffmpeg/package/package.json
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@ffmpeg/ffmpeg",
|
3 |
+
"version": "0.12.7",
|
4 |
+
"description": "FFmpeg WebAssembly version for browser",
|
5 |
+
"main": "./dist/umd/ffmpeg.js",
|
6 |
+
"types": "./dist/esm/index.d.ts",
|
7 |
+
"exports": {
|
8 |
+
".": {
|
9 |
+
"types": "./dist/esm/index.d.ts",
|
10 |
+
"node": "./dist/esm/empty.mjs",
|
11 |
+
"default": {
|
12 |
+
"import": "./dist/esm/index.js",
|
13 |
+
"require": "./dist/umd/ffmpeg.js"
|
14 |
+
}
|
15 |
+
}
|
16 |
+
},
|
17 |
+
"scripts": {
|
18 |
+
"dev": "webpack -w --mode development",
|
19 |
+
"lint": "eslint src",
|
20 |
+
"clean": "rimraf dist",
|
21 |
+
"build:esm": "tsc -p tsconfig.esm.json",
|
22 |
+
"build:umd": "webpack",
|
23 |
+
"build": "npm run clean && npm run build:esm && npm run build:umd",
|
24 |
+
"prepublishOnly": "npm run build"
|
25 |
+
},
|
26 |
+
"files": [
|
27 |
+
"dist",
|
28 |
+
"types/ffmpeg.d.ts"
|
29 |
+
],
|
30 |
+
"repository": {
|
31 |
+
"type": "git",
|
32 |
+
"url": "git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"
|
33 |
+
},
|
34 |
+
"keywords": [
|
35 |
+
"ffmpeg",
|
36 |
+
"WebAssembly",
|
37 |
+
"video",
|
38 |
+
"audio",
|
39 |
+
"transcode"
|
40 |
+
],
|
41 |
+
"author": "Jerome Wu <[email protected]>",
|
42 |
+
"license": "MIT",
|
43 |
+
"bugs": {
|
44 |
+
"url": "https://github.com/ffmpegwasm/ffmpeg.wasm/issues"
|
45 |
+
},
|
46 |
+
"engines": {
|
47 |
+
"node": ">=18.x"
|
48 |
+
},
|
49 |
+
"homepage": "https://github.com/ffmpegwasm/ffmpeg.wasm#readme",
|
50 |
+
"publishConfig": {
|
51 |
+
"access": "public"
|
52 |
+
},
|
53 |
+
"devDependencies": {
|
54 |
+
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
55 |
+
"@typescript-eslint/parser": "^6.1.0",
|
56 |
+
"eslint": "^8.45.0",
|
57 |
+
"rimraf": "^5.0.1",
|
58 |
+
"typescript": "^5.1.6",
|
59 |
+
"webpack-cli": "^5.1.4"
|
60 |
+
},
|
61 |
+
"dependencies": {
|
62 |
+
"@ffmpeg/types": "^0.12.2"
|
63 |
+
}
|
64 |
+
}
|
assets/util/package/dist/cjs/const.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export declare const HeaderContentLength = "Content-Length";
|
assets/util/package/dist/cjs/const.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
+
exports.HeaderContentLength = void 0;
|
4 |
+
exports.HeaderContentLength = "Content-Length";
|
assets/util/package/dist/cjs/errors.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export declare const ERROR_RESPONSE_BODY_READER: Error;
|
2 |
+
export declare const ERROR_INCOMPLETED_DOWNLOAD: Error;
|
assets/util/package/dist/cjs/errors.js
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
+
exports.ERROR_INCOMPLETED_DOWNLOAD = exports.ERROR_RESPONSE_BODY_READER = void 0;
|
4 |
+
exports.ERROR_RESPONSE_BODY_READER = new Error("failed to get response body reader");
|
5 |
+
exports.ERROR_INCOMPLETED_DOWNLOAD = new Error("failed to complete download");
|
assets/util/package/dist/cjs/index.d.ts
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ProgressCallback } from "./types.js";
|
2 |
+
/**
|
3 |
+
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
4 |
+
*
|
5 |
+
* Examples:
|
6 |
+
* ```ts
|
7 |
+
* // URL
|
8 |
+
* await fetchFile("http://localhost:3000/video.mp4");
|
9 |
+
* // base64
|
10 |
+
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
11 |
+
* // URL
|
12 |
+
* await fetchFile(new URL("video.mp4", import.meta.url));
|
13 |
+
* // File
|
14 |
+
* fileInput.addEventListener('change', (e) => {
|
15 |
+
* await fetchFile(e.target.files[0]);
|
16 |
+
* });
|
17 |
+
* // Blob
|
18 |
+
* const blob = new Blob(...);
|
19 |
+
* await fetchFile(blob);
|
20 |
+
* ```
|
21 |
+
*/
|
22 |
+
export declare const fetchFile: (file?: string | File | Blob) => Promise<Uint8Array>;
|
23 |
+
/**
|
24 |
+
* importScript dynamically import a script, useful when you
|
25 |
+
* want to use different versions of ffmpeg.wasm based on environment.
|
26 |
+
*
|
27 |
+
* Example:
|
28 |
+
*
|
29 |
+
* ```ts
|
30 |
+
* await importScript("http://localhost:3000/ffmpeg.js");
|
31 |
+
* ```
|
32 |
+
*/
|
33 |
+
export declare const importScript: (url: string) => Promise<void>;
|
34 |
+
/**
|
35 |
+
* Download content of a URL with progress.
|
36 |
+
*
|
37 |
+
* Progress only works when Content-Length is provided by the server.
|
38 |
+
*
|
39 |
+
*/
|
40 |
+
export declare const downloadWithProgress: (url: string | URL, cb?: ProgressCallback) => Promise<ArrayBuffer>;
|
41 |
+
/**
|
42 |
+
* toBlobURL fetches data from an URL and return a blob URL.
|
43 |
+
*
|
44 |
+
* Example:
|
45 |
+
*
|
46 |
+
* ```ts
|
47 |
+
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
48 |
+
* ```
|
49 |
+
*/
|
50 |
+
export declare const toBlobURL: (url: string, mimeType: string, progress?: boolean, cb?: ProgressCallback) => Promise<string>;
|
assets/util/package/dist/cjs/index.js
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 |
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 |
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5 |
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 |
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 |
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 |
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 |
+
});
|
10 |
+
};
|
11 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12 |
+
exports.toBlobURL = exports.downloadWithProgress = exports.importScript = exports.fetchFile = void 0;
|
13 |
+
const errors_js_1 = require("./errors.js");
|
14 |
+
const const_js_1 = require("./const.js");
|
15 |
+
const readFromBlobOrFile = (blob) => new Promise((resolve, reject) => {
|
16 |
+
const fileReader = new FileReader();
|
17 |
+
fileReader.onload = () => {
|
18 |
+
const { result } = fileReader;
|
19 |
+
if (result instanceof ArrayBuffer) {
|
20 |
+
resolve(new Uint8Array(result));
|
21 |
+
}
|
22 |
+
else {
|
23 |
+
resolve(new Uint8Array());
|
24 |
+
}
|
25 |
+
};
|
26 |
+
fileReader.onerror = (event) => {
|
27 |
+
var _a, _b;
|
28 |
+
reject(Error(`File could not be read! Code=${((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.code) || -1}`));
|
29 |
+
};
|
30 |
+
fileReader.readAsArrayBuffer(blob);
|
31 |
+
});
|
32 |
+
/**
|
33 |
+
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
34 |
+
*
|
35 |
+
* Examples:
|
36 |
+
* ```ts
|
37 |
+
* // URL
|
38 |
+
* await fetchFile("http://localhost:3000/video.mp4");
|
39 |
+
* // base64
|
40 |
+
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
41 |
+
* // URL
|
42 |
+
* await fetchFile(new URL("video.mp4", import.meta.url));
|
43 |
+
* // File
|
44 |
+
* fileInput.addEventListener('change', (e) => {
|
45 |
+
* await fetchFile(e.target.files[0]);
|
46 |
+
* });
|
47 |
+
* // Blob
|
48 |
+
* const blob = new Blob(...);
|
49 |
+
* await fetchFile(blob);
|
50 |
+
* ```
|
51 |
+
*/
|
52 |
+
const fetchFile = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
53 |
+
let data;
|
54 |
+
if (typeof file === "string") {
|
55 |
+
/* From base64 format */
|
56 |
+
if (/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(file)) {
|
57 |
+
data = atob(file.split(",")[1])
|
58 |
+
.split("")
|
59 |
+
.map((c) => c.charCodeAt(0));
|
60 |
+
/* From remote server/URL */
|
61 |
+
}
|
62 |
+
else {
|
63 |
+
data = yield (yield fetch(file)).arrayBuffer();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
else if (file instanceof URL) {
|
67 |
+
data = yield (yield fetch(file)).arrayBuffer();
|
68 |
+
}
|
69 |
+
else if (file instanceof File || file instanceof Blob) {
|
70 |
+
data = yield readFromBlobOrFile(file);
|
71 |
+
}
|
72 |
+
else {
|
73 |
+
return new Uint8Array();
|
74 |
+
}
|
75 |
+
return new Uint8Array(data);
|
76 |
+
});
|
77 |
+
exports.fetchFile = fetchFile;
|
78 |
+
/**
|
79 |
+
* importScript dynamically import a script, useful when you
|
80 |
+
* want to use different versions of ffmpeg.wasm based on environment.
|
81 |
+
*
|
82 |
+
* Example:
|
83 |
+
*
|
84 |
+
* ```ts
|
85 |
+
* await importScript("http://localhost:3000/ffmpeg.js");
|
86 |
+
* ```
|
87 |
+
*/
|
88 |
+
const importScript = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
89 |
+
return new Promise((resolve) => {
|
90 |
+
const script = document.createElement("script");
|
91 |
+
const eventHandler = () => {
|
92 |
+
script.removeEventListener("load", eventHandler);
|
93 |
+
resolve();
|
94 |
+
};
|
95 |
+
script.src = url;
|
96 |
+
script.type = "text/javascript";
|
97 |
+
script.addEventListener("load", eventHandler);
|
98 |
+
document.getElementsByTagName("head")[0].appendChild(script);
|
99 |
+
});
|
100 |
+
});
|
101 |
+
exports.importScript = importScript;
|
102 |
+
/**
|
103 |
+
* Download content of a URL with progress.
|
104 |
+
*
|
105 |
+
* Progress only works when Content-Length is provided by the server.
|
106 |
+
*
|
107 |
+
*/
|
108 |
+
const downloadWithProgress = (url, cb) => __awaiter(void 0, void 0, void 0, function* () {
|
109 |
+
var _a;
|
110 |
+
const resp = yield fetch(url);
|
111 |
+
let buf;
|
112 |
+
try {
|
113 |
+
// Set total to -1 to indicate that there is not Content-Type Header.
|
114 |
+
const total = parseInt(resp.headers.get(const_js_1.HeaderContentLength) || "-1");
|
115 |
+
const reader = (_a = resp.body) === null || _a === void 0 ? void 0 : _a.getReader();
|
116 |
+
if (!reader)
|
117 |
+
throw errors_js_1.ERROR_RESPONSE_BODY_READER;
|
118 |
+
const chunks = [];
|
119 |
+
let received = 0;
|
120 |
+
for (;;) {
|
121 |
+
const { done, value } = yield reader.read();
|
122 |
+
const delta = value ? value.length : 0;
|
123 |
+
if (done) {
|
124 |
+
if (total != -1 && total !== received)
|
125 |
+
throw errors_js_1.ERROR_INCOMPLETED_DOWNLOAD;
|
126 |
+
cb && cb({ url, total, received, delta, done });
|
127 |
+
break;
|
128 |
+
}
|
129 |
+
chunks.push(value);
|
130 |
+
received += delta;
|
131 |
+
cb && cb({ url, total, received, delta, done });
|
132 |
+
}
|
133 |
+
const data = new Uint8Array(received);
|
134 |
+
let position = 0;
|
135 |
+
for (const chunk of chunks) {
|
136 |
+
data.set(chunk, position);
|
137 |
+
position += chunk.length;
|
138 |
+
}
|
139 |
+
buf = data.buffer;
|
140 |
+
}
|
141 |
+
catch (e) {
|
142 |
+
console.log(`failed to send download progress event: `, e);
|
143 |
+
// Fetch arrayBuffer directly when it is not possible to get progress.
|
144 |
+
buf = yield resp.arrayBuffer();
|
145 |
+
cb &&
|
146 |
+
cb({
|
147 |
+
url,
|
148 |
+
total: buf.byteLength,
|
149 |
+
received: buf.byteLength,
|
150 |
+
delta: 0,
|
151 |
+
done: true,
|
152 |
+
});
|
153 |
+
}
|
154 |
+
return buf;
|
155 |
+
});
|
156 |
+
exports.downloadWithProgress = downloadWithProgress;
|
157 |
+
/**
|
158 |
+
* toBlobURL fetches data from an URL and return a blob URL.
|
159 |
+
*
|
160 |
+
* Example:
|
161 |
+
*
|
162 |
+
* ```ts
|
163 |
+
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
164 |
+
* ```
|
165 |
+
*/
|
166 |
+
const toBlobURL = (url, mimeType, progress = false, cb) => __awaiter(void 0, void 0, void 0, function* () {
|
167 |
+
const buf = progress
|
168 |
+
? yield (0, exports.downloadWithProgress)(url, cb)
|
169 |
+
: yield (yield fetch(url)).arrayBuffer();
|
170 |
+
const blob = new Blob([buf], { type: mimeType });
|
171 |
+
return URL.createObjectURL(blob);
|
172 |
+
});
|
173 |
+
exports.toBlobURL = toBlobURL;
|
assets/util/package/dist/cjs/types.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export interface DownloadProgressEvent {
|
2 |
+
url: string | URL;
|
3 |
+
total: number;
|
4 |
+
received: number;
|
5 |
+
delta: number;
|
6 |
+
done: boolean;
|
7 |
+
}
|
8 |
+
export type ProgressCallback = (event: DownloadProgressEvent) => void;
|
assets/util/package/dist/cjs/types.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
assets/util/package/dist/esm/const.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export declare const HeaderContentLength = "Content-Length";
|
assets/util/package/dist/esm/const.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export const HeaderContentLength = "Content-Length";
|
assets/util/package/dist/esm/errors.d.ts
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export declare const ERROR_RESPONSE_BODY_READER: Error;
|
2 |
+
export declare const ERROR_INCOMPLETED_DOWNLOAD: Error;
|
assets/util/package/dist/esm/errors.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
export const ERROR_RESPONSE_BODY_READER = new Error("failed to get response body reader");
|
2 |
+
export const ERROR_INCOMPLETED_DOWNLOAD = new Error("failed to complete download");
|
assets/util/package/dist/esm/index.d.ts
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ProgressCallback } from "./types.js";
|
2 |
+
/**
|
3 |
+
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
4 |
+
*
|
5 |
+
* Examples:
|
6 |
+
* ```ts
|
7 |
+
* // URL
|
8 |
+
* await fetchFile("http://localhost:3000/video.mp4");
|
9 |
+
* // base64
|
10 |
+
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
11 |
+
* // URL
|
12 |
+
* await fetchFile(new URL("video.mp4", import.meta.url));
|
13 |
+
* // File
|
14 |
+
* fileInput.addEventListener('change', (e) => {
|
15 |
+
* await fetchFile(e.target.files[0]);
|
16 |
+
* });
|
17 |
+
* // Blob
|
18 |
+
* const blob = new Blob(...);
|
19 |
+
* await fetchFile(blob);
|
20 |
+
* ```
|
21 |
+
*/
|
22 |
+
export declare const fetchFile: (file?: string | File | Blob) => Promise<Uint8Array>;
|
23 |
+
/**
|
24 |
+
* importScript dynamically import a script, useful when you
|
25 |
+
* want to use different versions of ffmpeg.wasm based on environment.
|
26 |
+
*
|
27 |
+
* Example:
|
28 |
+
*
|
29 |
+
* ```ts
|
30 |
+
* await importScript("http://localhost:3000/ffmpeg.js");
|
31 |
+
* ```
|
32 |
+
*/
|
33 |
+
export declare const importScript: (url: string) => Promise<void>;
|
34 |
+
/**
|
35 |
+
* Download content of a URL with progress.
|
36 |
+
*
|
37 |
+
* Progress only works when Content-Length is provided by the server.
|
38 |
+
*
|
39 |
+
*/
|
40 |
+
export declare const downloadWithProgress: (url: string | URL, cb?: ProgressCallback) => Promise<ArrayBuffer>;
|
41 |
+
/**
|
42 |
+
* toBlobURL fetches data from an URL and return a blob URL.
|
43 |
+
*
|
44 |
+
* Example:
|
45 |
+
*
|
46 |
+
* ```ts
|
47 |
+
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
48 |
+
* ```
|
49 |
+
*/
|
50 |
+
export declare const toBlobURL: (url: string, mimeType: string, progress?: boolean, cb?: ProgressCallback) => Promise<string>;
|
assets/util/package/dist/esm/index.js
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ERROR_RESPONSE_BODY_READER, ERROR_INCOMPLETED_DOWNLOAD, } from "./errors.js";
|
2 |
+
import { HeaderContentLength } from "./const.js";
|
3 |
+
const readFromBlobOrFile = (blob) => new Promise((resolve, reject) => {
|
4 |
+
const fileReader = new FileReader();
|
5 |
+
fileReader.onload = () => {
|
6 |
+
const { result } = fileReader;
|
7 |
+
if (result instanceof ArrayBuffer) {
|
8 |
+
resolve(new Uint8Array(result));
|
9 |
+
}
|
10 |
+
else {
|
11 |
+
resolve(new Uint8Array());
|
12 |
+
}
|
13 |
+
};
|
14 |
+
fileReader.onerror = (event) => {
|
15 |
+
reject(Error(`File could not be read! Code=${event?.target?.error?.code || -1}`));
|
16 |
+
};
|
17 |
+
fileReader.readAsArrayBuffer(blob);
|
18 |
+
});
|
19 |
+
/**
|
20 |
+
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
21 |
+
*
|
22 |
+
* Examples:
|
23 |
+
* ```ts
|
24 |
+
* // URL
|
25 |
+
* await fetchFile("http://localhost:3000/video.mp4");
|
26 |
+
* // base64
|
27 |
+
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
28 |
+
* // URL
|
29 |
+
* await fetchFile(new URL("video.mp4", import.meta.url));
|
30 |
+
* // File
|
31 |
+
* fileInput.addEventListener('change', (e) => {
|
32 |
+
* await fetchFile(e.target.files[0]);
|
33 |
+
* });
|
34 |
+
* // Blob
|
35 |
+
* const blob = new Blob(...);
|
36 |
+
* await fetchFile(blob);
|
37 |
+
* ```
|
38 |
+
*/
|
39 |
+
export const fetchFile = async (file) => {
|
40 |
+
let data;
|
41 |
+
if (typeof file === "string") {
|
42 |
+
/* From base64 format */
|
43 |
+
if (/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(file)) {
|
44 |
+
data = atob(file.split(",")[1])
|
45 |
+
.split("")
|
46 |
+
.map((c) => c.charCodeAt(0));
|
47 |
+
/* From remote server/URL */
|
48 |
+
}
|
49 |
+
else {
|
50 |
+
data = await (await fetch(file)).arrayBuffer();
|
51 |
+
}
|
52 |
+
}
|
53 |
+
else if (file instanceof URL) {
|
54 |
+
data = await (await fetch(file)).arrayBuffer();
|
55 |
+
}
|
56 |
+
else if (file instanceof File || file instanceof Blob) {
|
57 |
+
data = await readFromBlobOrFile(file);
|
58 |
+
}
|
59 |
+
else {
|
60 |
+
return new Uint8Array();
|
61 |
+
}
|
62 |
+
return new Uint8Array(data);
|
63 |
+
};
|
64 |
+
/**
|
65 |
+
* importScript dynamically import a script, useful when you
|
66 |
+
* want to use different versions of ffmpeg.wasm based on environment.
|
67 |
+
*
|
68 |
+
* Example:
|
69 |
+
*
|
70 |
+
* ```ts
|
71 |
+
* await importScript("http://localhost:3000/ffmpeg.js");
|
72 |
+
* ```
|
73 |
+
*/
|
74 |
+
export const importScript = async (url) => new Promise((resolve) => {
|
75 |
+
const script = document.createElement("script");
|
76 |
+
const eventHandler = () => {
|
77 |
+
script.removeEventListener("load", eventHandler);
|
78 |
+
resolve();
|
79 |
+
};
|
80 |
+
script.src = url;
|
81 |
+
script.type = "text/javascript";
|
82 |
+
script.addEventListener("load", eventHandler);
|
83 |
+
document.getElementsByTagName("head")[0].appendChild(script);
|
84 |
+
});
|
85 |
+
/**
|
86 |
+
* Download content of a URL with progress.
|
87 |
+
*
|
88 |
+
* Progress only works when Content-Length is provided by the server.
|
89 |
+
*
|
90 |
+
*/
|
91 |
+
export const downloadWithProgress = async (url, cb) => {
|
92 |
+
const resp = await fetch(url);
|
93 |
+
let buf;
|
94 |
+
try {
|
95 |
+
// Set total to -1 to indicate that there is not Content-Type Header.
|
96 |
+
const total = parseInt(resp.headers.get(HeaderContentLength) || "-1");
|
97 |
+
const reader = resp.body?.getReader();
|
98 |
+
if (!reader)
|
99 |
+
throw ERROR_RESPONSE_BODY_READER;
|
100 |
+
const chunks = [];
|
101 |
+
let received = 0;
|
102 |
+
for (;;) {
|
103 |
+
const { done, value } = await reader.read();
|
104 |
+
const delta = value ? value.length : 0;
|
105 |
+
if (done) {
|
106 |
+
if (total != -1 && total !== received)
|
107 |
+
throw ERROR_INCOMPLETED_DOWNLOAD;
|
108 |
+
cb && cb({ url, total, received, delta, done });
|
109 |
+
break;
|
110 |
+
}
|
111 |
+
chunks.push(value);
|
112 |
+
received += delta;
|
113 |
+
cb && cb({ url, total, received, delta, done });
|
114 |
+
}
|
115 |
+
const data = new Uint8Array(received);
|
116 |
+
let position = 0;
|
117 |
+
for (const chunk of chunks) {
|
118 |
+
data.set(chunk, position);
|
119 |
+
position += chunk.length;
|
120 |
+
}
|
121 |
+
buf = data.buffer;
|
122 |
+
}
|
123 |
+
catch (e) {
|
124 |
+
console.log(`failed to send download progress event: `, e);
|
125 |
+
// Fetch arrayBuffer directly when it is not possible to get progress.
|
126 |
+
buf = await resp.arrayBuffer();
|
127 |
+
cb &&
|
128 |
+
cb({
|
129 |
+
url,
|
130 |
+
total: buf.byteLength,
|
131 |
+
received: buf.byteLength,
|
132 |
+
delta: 0,
|
133 |
+
done: true,
|
134 |
+
});
|
135 |
+
}
|
136 |
+
return buf;
|
137 |
+
};
|
138 |
+
/**
|
139 |
+
* toBlobURL fetches data from an URL and return a blob URL.
|
140 |
+
*
|
141 |
+
* Example:
|
142 |
+
*
|
143 |
+
* ```ts
|
144 |
+
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
145 |
+
* ```
|
146 |
+
*/
|
147 |
+
export const toBlobURL = async (url, mimeType, progress = false, cb) => {
|
148 |
+
const buf = progress
|
149 |
+
? await downloadWithProgress(url, cb)
|
150 |
+
: await (await fetch(url)).arrayBuffer();
|
151 |
+
const blob = new Blob([buf], { type: mimeType });
|
152 |
+
return URL.createObjectURL(blob);
|
153 |
+
};
|
assets/util/package/dist/esm/types.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export interface DownloadProgressEvent {
|
2 |
+
url: string | URL;
|
3 |
+
total: number;
|
4 |
+
received: number;
|
5 |
+
delta: number;
|
6 |
+
done: boolean;
|
7 |
+
}
|
8 |
+
export type ProgressCallback = (event: DownloadProgressEvent) => void;
|
assets/util/package/dist/esm/types.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export {};
|
assets/util/package/dist/umd/index.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FFmpegUtil=t():e.FFmpegUtil=t()}(self,(()=>(()=>{"use strict";var e={591:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HeaderContentLength=void 0,t.HeaderContentLength="Content-Length"},431:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_INCOMPLETED_DOWNLOAD=t.ERROR_RESPONSE_BODY_READER=void 0,t.ERROR_RESPONSE_BODY_READER=new Error("failed to get response body reader"),t.ERROR_INCOMPLETED_DOWNLOAD=new Error("failed to complete download")},915:function(e,t,o){var r=this&&this.__awaiter||function(e,t,o,r){return new(o||(o=Promise))((function(n,i){function d(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(d,a)}l((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.toBlobURL=t.downloadWithProgress=t.importScript=t.fetchFile=void 0;const n=o(431),i=o(591);t.fetchFile=e=>r(void 0,void 0,void 0,(function*(){let t;if("string"==typeof e)t=/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(e)?atob(e.split(",")[1]).split("").map((e=>e.charCodeAt(0))):yield(yield fetch(e)).arrayBuffer();else if(e instanceof URL)t=yield(yield fetch(e)).arrayBuffer();else{if(!(e instanceof File||e instanceof Blob))return new Uint8Array;t=yield(o=e,new Promise(((e,t)=>{const r=new FileReader;r.onload=()=>{const{result:t}=r;t instanceof ArrayBuffer?e(new Uint8Array(t)):e(new Uint8Array)},r.onerror=e=>{var o,r;t(Error(`File could not be read! Code=${(null===(r=null===(o=null==e?void 0:e.target)||void 0===o?void 0:o.error)||void 0===r?void 0:r.code)||-1}`))},r.readAsArrayBuffer(o)})))}var o;return new Uint8Array(t)})),t.importScript=e=>r(void 0,void 0,void 0,(function*(){return new Promise((t=>{const o=document.createElement("script"),r=()=>{o.removeEventListener("load",r),t()};o.src=e,o.type="text/javascript",o.addEventListener("load",r),document.getElementsByTagName("head")[0].appendChild(o)}))})),t.downloadWithProgress=(e,t)=>r(void 0,void 0,void 0,(function*(){var o;const r=yield fetch(e);let d;try{const a=parseInt(r.headers.get(i.HeaderContentLength)||"-1"),l=null===(o=r.body)||void 0===o?void 0:o.getReader();if(!l)throw n.ERROR_RESPONSE_BODY_READER;const c=[];let s=0;for(;;){const{done:o,value:r}=yield l.read(),i=r?r.length:0;if(o){if(-1!=a&&a!==s)throw n.ERROR_INCOMPLETED_DOWNLOAD;t&&t({url:e,total:a,received:s,delta:i,done:o});break}c.push(r),s+=i,t&&t({url:e,total:a,received:s,delta:i,done:o})}const f=new Uint8Array(s);let u=0;for(const e of c)f.set(e,u),u+=e.length;d=f.buffer}catch(o){console.log("failed to send download progress event: ",o),d=yield r.arrayBuffer(),t&&t({url:e,total:d.byteLength,received:d.byteLength,delta:0,done:!0})}return d})),t.toBlobURL=(e,o,n=!1,i)=>r(void 0,void 0,void 0,(function*(){const r=n?yield(0,t.downloadWithProgress)(e,i):yield(yield fetch(e)).arrayBuffer(),d=new Blob([r],{type:o});return URL.createObjectURL(d)}))}},t={};return function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,o),i.exports}(915)})()));
|