Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit f238b4d

Browse files
committed
Use prepend.js to fix worker script loading issue
1 parent 17cd287 commit f238b4d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

wasm/build-scripts/build-ffmpeg.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ FLAGS=(
1212
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -lx265 -lvpx -lwavpack -lmp3lame -lfdk-aac -lvorbis -lvorbisenc -lvorbisfile -logg -ltheora -ltheoraenc -ltheoradec -lz -pthread
1313
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
1414
-o wasm/dist/ffmpeg-core.js
15+
--pre-js wasm/src/prepend.js # fix worker script issue
1516
-s USE_SDL=2 # use SDL2
1617
-s USE_PTHREADS=1 # enable pthreads support
1718
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread

wasm/src/prepend.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Module['locateFile'] = function(path, prefix) {
2+
if (typeof window !== 'undefined'
3+
&& typeof window.FFMPEG_CORE_WORKER_SCRIPT !== 'undefined'
4+
&& path.endsWith('ffmpeg-core.worker.js')) {
5+
return window.FFMPEG_CORE_WORKER_SCRIPT;
6+
}
7+
return prefix + path;
8+
}

0 commit comments

Comments
 (0)