Reorg folders and use core as ffmpeg from now on

This commit is contained in:
Jerome Wu
2022-09-22 13:06:44 +08:00
parent 4f03229810
commit 20790e4fd2
138 changed files with 10505 additions and 1223 deletions

View File

@@ -1,52 +1,50 @@
#!/bin/bash
# `-o <OUTPUT_FILE_NAME>` must be provided when using this build script.
# ex:
# bash ffmpeg-wasm.sh -o ffmpeg.js
EXTRA_CONF_FLAGS=(
-sINITIAL_MEMORY=32MB
-sALLOW_MEMORY_GROWTH
EXPORT_NAME="createFFmpeg"
CONF_FLAGS=(
-I.
-I./wasm/fftools
-I$INSTALL_DIR/include
-L$INSTALL_DIR/lib
-Llibavcodec
-Llibavdevice
-Llibavfilter
-Llibavformat
-Llibavutil
-Llibpostproc
-Llibswresample
-Llibswscale
-lavcodec
-lavdevice
-lavfilter
-lavformat
-lavutil
-lpostproc
-lswresample
-lswscale
-lx264
-Wno-deprecated-declarations
$LDFLAGS
-sUSE_SDL=2 # use emscripten SDL2 lib port
-sMODULARIZE # modularized to use as a library
${FFMPEG_MT:+ -sINITIAL_MEMORY=1024MB} # ALLOW_MEMORY_GROWTH is not recommended when using threads, thus we use a large initial memory
${FFMPEG_ST:+ -sINITIAL_MEMORY=32MB -sALLOW_MEMORY_GROWTH} # Use just enough memory as memory usage can grow
-sEXPORT_NAME="$EXPORT_NAME" # required in browser env, so that user can access this module from window.createFFmpeg
-sEXPORTED_FUNCTIONS=$(node wasm/bind/ffmpeg/export.js) # exported functions
-sEXPORTED_RUNTIME_METHODS=$(node wasm/bind/ffmpeg/export-runtime.js) # exported built-in functions
--pre-js wasm/bind/ffmpeg/bind.js # extra bindings, contains most of the ffmpeg.wasm javascript code
# ffmpeg source code
wasm/fftools/cmdutils.c
wasm/fftools/ffmpeg.c
wasm/fftools/ffmpeg_filter.c
wasm/fftools/ffmpeg_hw.c
wasm/fftools/ffmpeg_mux.c
wasm/fftools/ffmpeg_opt.c
wasm/fftools/opt_common.c
)
if [[ ! -z "$FFMPEG_MT" ]]; then
EXTRA_CONF_FLAGS=(
-sINITIAL_MEMORY=1024MB
)
fi
emcc \
-I. \
-I./wasm/fftools \
-I$INSTALL_DIR/include \
-L$INSTALL_DIR/lib \
-Llibavcodec \
-Llibavdevice \
-Llibavfilter \
-Llibavformat \
-Llibavutil \
-Llibpostproc \
-Llibswresample \
-Llibswscale \
-lavcodec \
-lavdevice \
-lavfilter \
-lavformat \
-lavutil \
-lpostproc \
-lswresample \
-lswscale \
-lx264 \
-Wno-deprecated-declarations \
$LDFLAGS \
-sUSE_SDL=2 \
-sMODULARIZE \
-sEXPORT_NAME="createFFmpegCore" \
-sEXPORTED_FUNCTIONS=$(node wasm/bind/export.js) \
-sEXPORTED_RUNTIME_METHODS=$(node wasm/bind/export-runtime.js) \
--pre-js wasm/bind/bind.js \
wasm/fftools/ffmpeg.c \
wasm/fftools/ffmpeg_filter.c \
wasm/fftools/ffmpeg_hw.c \
wasm/fftools/ffmpeg_mux.c \
wasm/fftools/ffmpeg_opt.c \
wasm/fftools/cmdutils.c \
wasm/fftools/opt_common.c \
${EXTRA_CONF_FLAGS[@]} \
$@
emcc "${CONF_FLAGS[@]}" $@

View File

@@ -1,37 +1,35 @@
#!/bin/bash
EXTRA_CONF_FLAGS=(
--disable-pthreads
--disable-w32threads
--disable-os2threads
CONF_FLAGS=(
--target-os=none # disable target specific configs
--arch=x86_32 # use x86_32 arch
--enable-cross-compile # use cross compile configs
--disable-asm # disable asm
--disable-stripping # disable stripping as it won't work
--disable-programs # disable ffmpeg, ffprobe and ffplay build
--disable-doc # disable doc build
--disable-debug # disable debug mode
--disable-runtime-cpudetect # disable cpu detection
--disable-autodetect # disable env auto detect
# assign toolchains and extra flags
--nm="llvm-nm"
--ar=emar
--ranlib=emranlib
--cc=emcc
--cxx=em++
--objcc=emcc
--dep-cc=emcc
--extra-cflags="$CFLAGS"
--extra-cxxflags="$CFLAGS"
# disable thread when FFMPEG_ST is NOT defined
${FFMPEG_ST:+ --disable-pthreads --disable-w32threads --disable-os2threads}
# extra libraries
--enable-gpl
--enable-libx264
)
if [[ ! -z "$FFMPEG_MT" ]]; then
EXTRA_CONF_FLAGS=()
fi
emconfigure ./configure \
--target-os=none \
--arch=x86_32 \
--enable-cross-compile \
--disable-asm \
--disable-stripping \
--disable-programs \
--disable-doc \
--disable-debug \
--disable-runtime-cpudetect \
--disable-autodetect \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CFLAGS" \
--nm="llvm-nm" \
--ar=emar \
--ranlib=emranlib \
--cc=emcc \
--cxx=em++ \
--objcc=emcc \
--dep-cc=emcc \
${EXTRA_CONF_FLAGS[@]} \
--enable-gpl \
--enable-libx264
emconfigure ./configure "${CONF_FLAGS[@]}"
emmake make -j

View File

@@ -1,20 +1,16 @@
#!/bin/bash
EXTRA_CONF_FLAGS=(
--disable-thread
set -euo pipefail
CONF_FLAGS=(
--prefix=$INSTALL_DIR # lib installation dir
--host=x86-gnu # use x86 linux host
--enable-static # build static library
--disable-cli # disable cli build
--disable-asm # disable assembly
--extra-cflags="$CFLAGS" # add extra cflags
${FFMPEG_ST:+ --disable-thread} # disable thread when FFMPEG_ST is defined
)
if [[ ! -z "$FFMPEG_MT" ]]; then
EXTRA_CONF_FLAGS=()
fi
emconfigure ./configure \
--prefix=$INSTALL_DIR \
--host=x86-gnu \
--enable-static \
--disable-cli \
--disable-asm \
--extra-cflags="$CFLAGS" \
${EXTRA_CONF_FLAGS[@]}
emconfigure ./configure "${CONF_FLAGS[@]}"
emmake make install-lib-static -j