File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -184,13 +184,19 @@ export class FFmpeg {
184
184
* @returns `true` if ffmpeg core is loaded for the first time.
185
185
*/
186
186
public load = (
187
- config : FFMessageLoadConfig = { } ,
187
+ { classWorkerURL , ... config } : FFMessageLoadConfig = { } ,
188
188
{ signal } : FFMessageOptions = { }
189
189
) : Promise < IsFirst > => {
190
190
if ( ! this . #worker) {
191
- this . #worker = new Worker ( new URL ( "./worker.js" , import . meta. url ) , {
192
- type : "module" ,
193
- } ) ;
191
+ this . #worker = classWorkerURL ?
192
+ new Worker ( new URL ( classWorkerURL , import . meta. url ) , {
193
+ type : "module" ,
194
+ } ) :
195
+ // We need to duplicated the code here to enable webpack
196
+ // to bundle worekr.js here.
197
+ new Worker ( new URL ( "./worker.js" , import . meta. url ) , {
198
+ type : "module" ,
199
+ } ) ;
194
200
this . #registerHandlers( ) ;
195
201
}
196
202
return this . #send(
Original file line number Diff line number Diff line change @@ -17,11 +17,19 @@ export interface FFMessageLoadConfig {
17
17
*/
18
18
wasmURL ?: string ;
19
19
/**
20
- * `ffmpeg-core.worker.js` URL.
20
+ * `ffmpeg-core.worker.js` URL. This worker is spawned when using multithread version of ffmpeg-core.
21
21
*
22
+ * @ref : https://ffmpegwasm.netlify.app/docs/overview#architecture
22
23
* @defaultValue `https://unpkg.com/@ffmpeg/core-mt@${CORE_VERSION}/dist/umd/ffmpeg-core.worker.js`;
23
24
*/
24
25
workerURL ?: string ;
26
+ /**
27
+ * `ffmpeg.worker.js` URL. This worker is spawned when FFmpeg.load() is called, it is an essential worker and usually you don't need to update this config.
28
+ *
29
+ * @ref : https://ffmpegwasm.netlify.app/docs/overview#architecture
30
+ * @defaultValue `./worker.js`
31
+ */
32
+ classWorkerURL ?: string ;
25
33
}
26
34
27
35
export interface FFMessageExecData {
You can’t perform that action at this time.
0 commit comments