Created
October 2, 2022 17:29
-
-
Save WeZZard/700a2c13354954f443becd2e69c0112f to your computer and use it in GitHub Desktop.
ffmpeg wasm + emscript build script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# verify Emscripten version | |
emcc -v | |
# build ffmpeg.wasm | |
mkdir -p wasm/dist | |
ARGS=( | |
-I. -I./fftools | |
-Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample | |
-Qunused-arguments | |
-o wasm/dist/ffmpeg.js | |
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c | |
fftools/cmdutils.c fftools/ffmpeg.c fftools/sync_queue.c | |
fftools/ffmpeg_mux.c fftools/ffmpeg_demux.c fftools/opt_common.c | |
fftools/objpool.c fftools/thread_queue.c | |
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lm | |
-lnodefs.js | |
-O3 # Optimize code with performance first | |
-s USE_SDL=2 # use SDL2 | |
-s USE_PTHREADS=1 # enable pthreads support | |
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread | |
-s EXPORTED_FUNCTIONS="[_main, __emscripten_proxy_main]" # export main func | |
-s EXPORTED_RUNTIME_METHODS="[FS, cwrap, setValue, writeAsciiToMemory]" # export preamble funcs | |
-s INITIAL_MEMORY=33554432 # 33554432 bytes = 32 MB | |
-s LLD_REPORT_UNDEFINED | |
-s ALLOW_MEMORY_GROWTH=1 | |
-s EXIT_RUNTIME=1 | |
) | |
emcc "${ARGS[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# verify Emscripten version | |
emcc -v | |
# configure FFMpeg with Emscripten | |
CFLAGS="-s USE_PTHREADS" | |
LDFLAGS="$CFLAGS -s INITIAL_MEMORY=33554432" # 33554432 bytes = 32 MB | |
CONFIG_ARGS=( | |
--target-os=none # use none to prevent any os specific configurations | |
--arch=x86_32 # use x86_32 to achieve minimal architectural optimization | |
--enable-cross-compile # enable cross compile | |
--disable-x86asm # disable x86 asm | |
--disable-inline-asm # disable inline asm | |
--disable-stripping # disable stripping | |
--disable-programs # disable programs build (incl. ffplay, ffprobe & ffmpeg) | |
--disable-doc # disable doc | |
--extra-cflags="$CFLAGS" | |
--extra-cxxflags="$CFLAGS" | |
--extra-ldflags="$LDFLAGS" | |
--nm="llvm-nm" | |
--ar=emar | |
--ranlib=emranlib | |
--cc=emcc | |
--cxx=em++ | |
--objcc=emcc | |
--dep-cc=emcc | |
) | |
emconfigure ./configure "${CONFIG_ARGS[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
# verify Emscripten version | |
emcc -v | |
# build dependencies | |
emmake make -j4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment