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 {
184184 * @returns `true` if ffmpeg core is loaded for the first time.
185185 */
186186 public load = (
187- config : FFMessageLoadConfig = { } ,
187+ { classWorkerURL , ... config } : FFMessageLoadConfig = { } ,
188188 { signal } : FFMessageOptions = { }
189189 ) : Promise < IsFirst > => {
190190 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+ } ) ;
194200 this . #registerHandlers( ) ;
195201 }
196202 return this . #send(
Original file line number Diff line number Diff line change @@ -17,11 +17,19 @@ export interface FFMessageLoadConfig {
1717 */
1818 wasmURL ?: string ;
1919 /**
20- * `ffmpeg-core.worker.js` URL.
20+ * `ffmpeg-core.worker.js` URL. This worker is spawned when using multithread version of ffmpeg-core.
2121 *
22+ * @ref : https://ffmpegwasm.netlify.app/docs/overview#architecture
2223 * @defaultValue `https://unpkg.com/@ffmpeg/core-mt@${CORE_VERSION}/dist/umd/ffmpeg-core.worker.js`;
2324 */
2425 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 ;
2533}
2634
2735export interface FFMessageExecData {
You can’t perform that action at this time.
0 commit comments