-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-js-debug.sh
executable file
·92 lines (84 loc) · 2.07 KB
/
build-js-debug.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash -x
ROOT_DIR=$PWD
##
configure_ffmpeg() {
cd build/FFmpeg
echo "Make clean"
make clean
echo "Preparing configure"
emconfigure ./configure \
--nm="llvm-nm -g" \
--cxx=em++ \
--ar=emar \
--as=llvm-as \
--ranlib=llvm-ranlib \
--cc=emcc \
--objcc=emcc \
--dep-cc=emcc \
--enable-cross-compile \
--target-os=none \
--arch=i686 \
--disable-runtime-cpudetect \
--disable-asm \
--disable-fast-unaligned \
--disable-pthreads \
--disable-w32threads \
--disable-os2threads \
--disable-debug \
--disable-stripping \
\
--disable-all \
--enable-ffmpeg \
--enable-avcodec \
--enable-avformat \
--enable-avutil \
--enable-swresample \
--enable-swscale \
--enable-avfilter \
--disable-network \
--disable-d3d11va \
--disable-dxva2 \
--disable-vaapi \
--disable-vdpau \
--enable-decoder=h264 \
--enable-decoder=vp9 \
--enable-decoder=vp8 \
--enable-decoder=hevc \
--enable-protocol=file \
--disable-bzlib \
--disable-iconv \
--disable-libxcb \
--disable-lzma \
--disable-securetransport \
--disable-xlib \
--disable-zlib
}
make_ffmpeg() {
NPROC=$(grep -c ^processor /proc/cpuinfo)
echo "Making ffmpeg.bc"
emmake make -j${NPROC} && cp ffmpeg ffmpeg.bc
}
build_ffmpegjs() {
cd $ROOT_DIR
echo "Emscriting ffmpeg into js"
emcc build/FFmpeg/ffmpeg.bc \
-o dist/ffmpeg-h264.js \
-s MODULARIZE=1 \
--memory-init-file 0 \
-s WASM=1 \
-g4 \
--js-opts 0 \
-s ASSERTIONS=2 \
-s SAFE_HEAP=1 \
-s SINGLE_FILE=1 \
-s NO_EXIT_RUNTIME=1 \
-s EXPORTED_FUNCTIONS='["_avcodec_register_all","_avcodec_find_decoder_by_name","_avcodec_alloc_context3","_avcodec_open2", "_av_init_packet", "_av_frame_alloc", "_av_packet_from_data", "_avcodec_decode_video2", "_avcodec_flush_buffers"]' \
-s EXTRA_EXPORTED_RUNTIME_METHODS='["FS", "ccall", "getValue", "setValue", "writeArrayToMemory"]' \
-s TOTAL_MEMORY=134217728
}
main() {
configure_ffmpeg
make_ffmpeg
build_ffmpegjs
}
main "$@"