Skip to content

Commit fd5bd79

Browse files
author
Elliot Schep
committed
Merge remote-tracking branch 'upstream/n4.3.1-wasm' into android-fix
* upstream/n4.3.1-wasm: Update core-st package.json Minor update build scripts and release 0.11.0 Build some "core" variations. (ffmpegwasm#16) ios support (ffmpegwasm#15) Revert "Upgrade to emscripten v2.0.24" (ffmpegwasm#14) export stringToUTF8() for Unicode characters (ffmpegwasm#12)
2 parents 62a33e9 + 1f3461d commit fd5bd79

25 files changed

+194
-60
lines changed

build-with-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -euo pipefail
44

5-
EM_VERSION=2.0.24
5+
EM_VERSION=2.0.8
66

77
docker pull emscripten/emsdk:$EM_VERSION
88
docker run \

build.sh

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,29 @@ run-all() {
1414
SCRIPTS=(
1515
# install dependencies
1616
install-deps
17-
build-zlib
18-
build-x264
19-
build-x265
20-
build-libvpx
21-
build-wavpack
22-
build-lame
23-
build-fdk-aac
24-
build-ogg
25-
build-vorbis
26-
build-theora
27-
build-opus
28-
build-libwebp
29-
build-freetype2
30-
build-fribidi
31-
build-harfbuzz
32-
build-libass
33-
#build-aom # disabled as it is extremely slow
34-
configure-ffmpeg
17+
build-zlib
18+
build-x264
19+
build-x265
20+
build-libvpx
21+
build-wavpack
22+
build-lame
23+
build-fdk-aac
24+
build-ogg
25+
build-vorbis
26+
build-theora
27+
build-opus
28+
build-libwebp
29+
build-freetype2
30+
build-fribidi
31+
build-harfbuzz
32+
build-libass
33+
#build-aom # disabled as it is extremely slow
34+
configure-ffmpeg
3535
build-ffmpeg
36+
# configure-ffmpeg.mp4-scale
37+
# build-ffmpeg.mp4-scale
38+
# configure-ffmpeg.png-to-mp4
39+
# build-ffmpeg.png-to-mp4
3640
)
3741
run ${SCRIPTS[@]}
3842
}

wasm/build-scripts/build-ffmpeg.mp4-scale.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,42 @@
33
set -eo pipefail
44
source $(dirname $0)/var.sh
55

6-
mkdir -p wasm/dist
7-
emmake make -j
6+
if [[ "$FFMPEG_ST" != "yes" ]]; then
7+
mkdir -p wasm/packages/core.mp4-scale/dist
8+
EXPORTED_FUNCTIONS="[_main, _proxy_main]"
9+
EXTRA_FLAGS=(
10+
-pthread
11+
-s USE_PTHREADS=1 # enable pthreads support
12+
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread
13+
-o wasm/packages/core.mp4-scale/dist/ffmpeg-core.js
14+
)
15+
else
16+
mkdir -p wasm/packages/core-st.mp4-scale/dist
17+
EXPORTED_FUNCTIONS="[_main]"
18+
EXTRA_FLAGS=(
19+
-o wasm/packages/core-st.mp4-scale/dist/ffmpeg-core.js
20+
)
21+
fi
22+
823
FLAGS=(
924
-I. -I./fftools -I$BUILD_DIR/include
1025
-Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -L$BUILD_DIR/lib
1126
-Wno-deprecated-declarations -Wno-pointer-sign -Wno-implicit-int-float-conversion -Wno-switch -Wno-parentheses -Qunused-arguments
12-
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -pthread
27+
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264
1328
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
14-
-o wasm/dist/ffmpeg-core.js
1529
-s USE_SDL=2 # use SDL2
16-
-s USE_PTHREADS=1 # enable pthreads support
17-
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread
1830
-s INVOKE_RUN=0 # not to run the main() in the beginning
1931
-s EXIT_RUNTIME=1 # exit runtime after execution
2032
-s MODULARIZE=1 # use modularized version to be more flexible
2133
-s EXPORT_NAME="createFFmpegCore" # assign export name for browser
22-
-s EXPORTED_FUNCTIONS="[_main, _proxy_main]" # export main and proxy_main funcs
34+
-s EXPORTED_FUNCTIONS="$EXPORTED_FUNCTIONS" # export main and proxy_main funcs
2335
-s EXTRA_EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory]" # export preamble funcs
2436
-s INITIAL_MEMORY=1073741824 # 1073741824 bytes = 1 GB
37+
--post-js wasm/src/post.js
38+
--pre-js wasm/src/pre.js
2539
$OPTIM_FLAGS
40+
${EXTRA_FLAGS[@]}
2641
)
2742
echo "FFMPEG_EM_FLAGS=${FLAGS[@]}"
43+
emmake make -j
2844
emcc "${FLAGS[@]}"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
source $(dirname $0)/var.sh
5+
6+
if [[ "$FFMPEG_ST" != "yes" ]]; then
7+
mkdir -p wasm/packages/core.png-to-mp4/dist
8+
EXPORTED_FUNCTIONS="[_main, _proxy_main]"
9+
EXTRA_FLAGS=(
10+
-pthread
11+
-s USE_PTHREADS=1 # enable pthreads support
12+
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread
13+
-o wasm/packages/core.png-to-mp4/dist/ffmpeg-core.js
14+
)
15+
else
16+
mkdir -p wasm/packages/core-st.png-to-mp4/dist
17+
EXPORTED_FUNCTIONS="[_main]"
18+
EXTRA_FLAGS=(
19+
-o wasm/packages/core-st.png-to-mp4/dist/ffmpeg-core.js
20+
)
21+
fi
22+
23+
FLAGS=(
24+
-I. -I./fftools -I$BUILD_DIR/include
25+
-Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -L$BUILD_DIR/lib
26+
-Wno-deprecated-declarations -Wno-pointer-sign -Wno-implicit-int-float-conversion -Wno-switch -Wno-parentheses -Qunused-arguments
27+
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -lz
28+
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
29+
-s USE_SDL=2 # use SDL2
30+
-s INVOKE_RUN=0 # not to run the main() in the beginning
31+
-s EXIT_RUNTIME=1 # exit runtime after execution
32+
-s MODULARIZE=1 # use modularized version to be more flexible
33+
-s EXPORT_NAME="createFFmpegCore" # assign export name for browser
34+
-s EXPORTED_FUNCTIONS="$EXPORTED_FUNCTIONS" # export main and proxy_main funcs
35+
-s EXTRA_EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory]" # export preamble funcs
36+
-s INITIAL_MEMORY=1073741824 # 1073741824 bytes = 1 GB
37+
--post-js wasm/src/post.js
38+
--pre-js wasm/src/pre.js
39+
$OPTIM_FLAGS
40+
${EXTRA_FLAGS[@]}
41+
)
42+
echo "FFMPEG_EM_FLAGS=${FLAGS[@]}"
43+
emmake make -j
44+
emcc "${FLAGS[@]}"

wasm/build-scripts/build-ffmpeg.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
#!/bin/bash
22

33
set -eo pipefail
4-
source $(dirname $0)/var.sh
4+
source $(dirname "$0")/var.sh
55

66
if [[ "$FFMPEG_ST" != "yes" ]]; then
77
mkdir -p wasm/packages/core/dist
8+
EXPORTED_FUNCTIONS="[_main, _proxy_main]"
89
EXTRA_FLAGS=(
910
-pthread
10-
-s USE_PTHREADS=1 # enable pthreads support
11-
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread
11+
-s USE_PTHREADS=1 # enable pthreads support
12+
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread
1213
-o wasm/packages/core/dist/ffmpeg-core.js
14+
-s INITIAL_MEMORY=1073741824 # 1GB
1315
)
1416
else
1517
mkdir -p wasm/packages/core-st/dist
18+
EXPORTED_FUNCTIONS="[_main]"
1619
EXTRA_FLAGS=(
1720
-o wasm/packages/core-st/dist/ffmpeg-core.js
21+
-s INITIAL_MEMORY=33554432 # 32MB
22+
-s MAXIMUM_MEMORY=1073741824 # 1GB
23+
-s ALLOW_MEMORY_GROWTH=1
1824
)
1925
fi
2026
FLAGS=(
@@ -24,19 +30,15 @@ FLAGS=(
2430
-Qunused-arguments
2531
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
2632
-lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lm -lharfbuzz -lfribidi -lass -lx264 -lx265 -lvpx -lwavpack -lmp3lame -lfdk-aac -lvorbis -lvorbisenc -lvorbisfile -logg -ltheora -ltheoraenc -ltheoradec -lz -lfreetype -lopus -lwebp
27-
-s USE_SDL=2 # use SDL2
28-
-s INVOKE_RUN=0 # not to run the main() in the beginning
29-
-s EXIT_RUNTIME=1 # exit runtime after execution
30-
-s MODULARIZE=1 # use modularized version to be more flexible
31-
-s EXPORT_NAME="createFFmpegCore" # assign export name for browser
32-
-s EXPORTED_FUNCTIONS="[_main]" # export main and proxy_main funcs
33-
-s EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory]" # export preamble funcs
34-
# -s INITIAL_MEMORY=2146435072 # 2146435072 bytes ~= 2 GB
35-
# -s TOTAL_MEMORY=33554432
36-
-s ALLOW_MEMORY_GROWTH=1
37-
-s INITIAL_MEMORY=33554432 # 33554432 bytes = 32 MB
38-
--pre-js wasm/src/pre.js
33+
-s USE_SDL=2 # use SDL2
34+
-s INVOKE_RUN=0 # not to run the main() in the beginning
35+
-s EXIT_RUNTIME=1 # exit runtime after execution
36+
-s MODULARIZE=1 # use modularized version to be more flexible
37+
-s EXPORT_NAME="createFFmpegCore" # assign export name for browser
38+
-s EXPORTED_FUNCTIONS="$EXPORTED_FUNCTIONS" # export main and proxy_main funcs
39+
-s EXTRA_EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory, lengthBytesUTF8, stringToUTF8, UTF8ToString]" # export preamble funcs
3940
--post-js wasm/src/post.js
41+
--pre-js wasm/src/pre.js
4042
$OPTIM_FLAGS
4143
${EXTRA_FLAGS[@]}
4244
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
source $(dirname $0)/var.sh
5+
6+
FLAGS=(
7+
"${FFMPEG_CONFIG_FLAGS_BASE[@]}"
8+
--disable-all
9+
--enable-gpl # required by x264
10+
--enable-libx264 # enable x264
11+
--enable-zlib # enable zlib
12+
--enable-avcodec
13+
--enable-avformat
14+
--enable-avfilter
15+
--enable-swresample
16+
--enable-swscale
17+
--enable-decoder=png
18+
--enable-encoder=png,libx264
19+
--enable-parser=h264,png
20+
--enable-protocol=file
21+
--enable-demuxer=image2
22+
--enable-muxer=mp4
23+
--enable-filter=scale,format,null
24+
25+
)
26+
echo "FFMPEG_CONFIG_FLAGS=${FLAGS[@]}"
27+
emconfigure ./configure "${FLAGS[@]}"

wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"start": "serve .",
8-
"test": "node --experimental-wasm-threads --experimental-wasm-bulk-memory ./node_modules/.bin/jest"
8+
"test": "node --experimental-wasm-threads --experimental-wasm-bulk-memory ./node_modules/.bin/jest --verbose"
99
},
1010
"author": "[email protected]",
1111
"license": "MIT",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

wasm/packages/core-st/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)