Last active
March 20, 2024 08:42
-
-
Save jeromewu/34ddf5e2d4d93657ba13565c3a5519b7 to your computer and use it in GitHub Desktop.
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 | |
# ... | |
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 | |
--enable-gpl ## required by x264 | |
--enable-libx264 ## enable x264 | |
--extra-cflags="$CFLAGS" | |
--extra-cxxflags="$CFLAGS" | |
--extra-ldflags="$LDFLAGS" | |
--nm="llvm-nm -g" | |
--ar=emar | |
--as=llvm-as | |
--ranlib=llvm-ranlib | |
--cc=emcc | |
--cxx=em++ | |
--objcc=emcc | |
--dep-cc=emcc | |
) | |
emconfigure ./configure "${CONFIG_ARGS[@]}" | |
# ... | |
ARGS=( | |
-I. -I./fftools -I$BUILD_DIR/include | |
-Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -L$BUILD_DIR/lib | |
-Qunused-arguments | |
-o wasm/dist/ffmpeg-core.js fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c | |
# Add -lpostproc and -lx264 below | |
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -pthread | |
-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 INVOKE_RUN=0 # not to run the main() in the beginning | |
-s EXPORTED_FUNCTIONS="[_main, _proxy_main]" # export main and proxy_main funcs | |
-s EXTRA_EXPORTED_RUNTIME_METHODS="[FS, cwrap, setValue, writeAsciiToMemory]" # export preamble funcs | |
-s INITIAL_MEMORY=268435456 ## increase to 268435456 bytes = 256 MB | |
) | |
emcc "${ARGS[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment