Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
9a04374f
Commit
9a04374f
authored
Sep 25, 2020
by
Jerome Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize bash scripts
parent
74e8907e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
51 deletions
+65
-51
build-with-docker.sh
build-with-docker.sh
+3
-3
build.sh
build.sh
+6
-9
build-ffmpeg.sh
wasm/build-scripts/build-ffmpeg.sh
+10
-9
build-x264.sh
wasm/build-scripts/build-x264.sh
+9
-19
configure-ffmpeg.sh
wasm/build-scripts/configure-ffmpeg.sh
+9
-6
make.sh
wasm/build-scripts/make.sh
+0
-5
var.sh
wasm/build-scripts/var.sh
+28
-0
No files found.
build-with-docker.sh
View file @
9a04374f
#!/bin/bash
-x
#!/bin/bash
set
-eo
pipefail
set
-e
u
o
pipefail
EM_VERSION
=
1.39.18-upstream
...
...
@@ -10,4 +10,4 @@ docker run \
-v
$PWD
:/src
\
-v
$PWD
/wasm/cache:/emsdk_portable/.data/cache/wasm
\
trzeci/emscripten:
$EM_VERSION
\
sh
-c
'bash
-x
./build.sh'
sh
-c
'bash ./build.sh'
build.sh
View file @
9a04374f
#!/bin/bash
-x
#!/bin/bash
set
-eo
pipefail
ROOT
=
$PWD
BUILD_DIR
=
$ROOT
/build
SCRIPT_ROOT
=
$(
dirname
$0
)
/wasm/build-scripts
# verify Emscripten version
emcc
-v
# build x264
$
ROOT
/wasm/build-scripts/build-x264.sh
$ROOT
/third_party/x264
$BUILD_DIR
$
SCRIPT_ROOT
/build-x264.sh
# configure FFmpeg with Emscripten
$ROOT
/wasm/build-scripts/configure.sh
$BUILD_DIR
# # build dependencies
$ROOT
/wasm/build-scripts/make.sh
# # build ffmpeg.wasm
$ROOT
/wasm/build-scripts/build-ffmpeg.sh
$BUILD_DIR
$SCRIPT_ROOT
/configure-ffmpeg.sh
# build ffmpeg.wasm
$SCRIPT_ROOT
/build-ffmpeg.sh
wasm/build-scripts/build-ffmpeg.sh
View file @
9a04374f
#!/bin/bash
-x
#!/bin/bash
set
-eo
pipefail
BUILD_DIR
=
$1
source
$(
dirname
$0
)
/var.sh
mkdir
-p
wasm/dist
ARGS
=(
emmake make
-j
FLAGS
=(
-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
-Wno-deprecated-declarations
-Wno-pointer-sign
-Wno-implicit-int-float-conversion
-Wno-switch
-Wno-parentheses
-Qunused-arguments
-lavdevice
-lavfilter
-lavformat
-lavcodec
-lswresample
-lswscale
-lavutil
-lpostproc
-lm
-lx264
-pthread
-O3
# optimize code with performance first
-
-closure
1
# code size optimization
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
-
o
wasm/dist/ffmpeg-core.js
-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
...
...
@@ -22,5 +21,7 @@ ARGS=(
-s
EXPORTED_FUNCTIONS
=
"[_main, _proxy_main]"
# export main and proxy_main funcs
-s
EXTRA_EXPORTED_RUNTIME_METHODS
=
"[FS, cwrap, ccall, setValue, writeAsciiToMemory]"
# export preamble funcs
-s
INITIAL_MEMORY
=
1073741824
# 1073741824 bytes = 1 GB
$OPTIM_FLAGS
)
emcc
"
${
ARGS
[@]
}
"
echo
"FFMPEG_EM_FLAGS=
${
FLAGS
[@]
}
"
emcc
"
${
FLAGS
[@]
}
"
wasm/build-scripts/build-x264.sh
View file @
9a04374f
#!/bin/bash
-x
#!/bin/bash
set
-eo
pipefail
set
-euo
pipefail
source
$(
dirname
$0
)
/var.sh
ROOT
=
$1
BUILD_DIR
=
$2
OPT_FLAGS
=
"-O3 --closure 1"
if
[[
"
$OSTYPE
"
==
"darwin"
*
]]
;
then
# As closure compiler requires java 6 and
# I don't find a way to install it in github actions
OPT_FLAGS
=
"-O3"
fi
cd
$ROOT
ARGS
=(
X264_PATH
=
third_party/x264
FLAGS
=(
--prefix
=
$BUILD_DIR
# install library in a build directory for FFmpeg to include
--host
=
i686-gnu
# use i686 linux
--enable-static
# enable building static library
--disable-cli
# disable cli tools
--disable-asm
# disable asm optimization
--extra-cflags
=
"-
s USE_PTHREADS=1
$OPT
_FLAGS
"
# flags to use pthread and code optimization
--extra-cflags
=
"-
c -s USE_PTHREADS=1
$OPTIM
_FLAGS
"
# flags to use pthread and code optimization
)
e
mconfigure ./configure
"
${
AR
GS
[@]
}
"
emmake make install-lib-static
-j4
cd
-
e
cho
"FLAGS=
${
FLA
GS
[@]
}
"
(
cd
$X264_PATH
&&
emconfigure ./configure
"
${
FLAGS
[@]
}
"
)
emmake make
-C
$X264_PATH
install-lib-static
-j
wasm/build-scripts/configure.sh
→
wasm/build-scripts/configure
-ffmpeg
.sh
View file @
9a04374f
#!/bin/bash
-x
#!/bin/bash
set
-eo
pipefail
set
-euo
pipefail
source
$(
dirname
$0
)
/var.sh
BUILD_DIR
=
$1
CFLAGS
=
"-s USE_PTHREADS -I
$BUILD_DIR
/include -O3 --closure 1"
CFLAGS
=
"-s USE_PTHREADS=1 -I
$BUILD_DIR
/include
$OPTIM_FLAGS
"
LDFLAGS
=
"
$CFLAGS
-L
$BUILD_DIR
/lib"
AR
GS
=(
FLA
GS
=(
--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
...
...
@@ -17,6 +17,8 @@ ARGS=(
--enable-gpl
# required by x264
--enable-libx264
# enable x264
--disable-debug
# disable debug info, required by closure
--disable-runtime-cpudetect
# disable runtime cpu detect
--disable-autodetect
# disable external libraries auto detect
--extra-cflags
=
"
$CFLAGS
"
--extra-cxxflags
=
"
$CFLAGS
"
--extra-ldflags
=
"
$LDFLAGS
"
...
...
@@ -29,4 +31,5 @@ ARGS=(
--objcc
=
emcc
--dep-cc
=
emcc
)
emconfigure ./configure
"
${
ARGS
[@]
}
"
echo
"FFMPEG_CONFIG_FLAGS=
${
FLAGS
[@]
}
"
emconfigure ./configure
"
${
FLAGS
[@]
}
"
wasm/build-scripts/make.sh
deleted
100755 → 0
View file @
74e8907e
#!/bin/bash -x
set
-eo
pipefail
emmake make
-j4
wasm/build-scripts/var.sh
0 → 100755
View file @
9a04374f
#!/bin/bash
#
# Common variables for all scripts
set
-euo
pipefail
# Flags for code optimization, focus on speed instead
# of size
OPTIM_FLAGS
=(
-O3
)
# Directory to install headers and libraries
BUILD_DIR
=
build
if
[[
"
$OSTYPE
"
==
"linux-gnu"
*
]]
;
then
# Use closure complier only in linux environment
OPTIM_FLAGS
=(
"
${
OPTIM_FLAGS
[@]
}
"
--closure
1
)
fi
# Convert array to string
OPTIM_FLAGS
=
"
${
OPTIM_FLAGS
[@]
}
"
echo
"OPTIM_FLAGS=
$OPTIM_FLAGS
"
echo
"BUILD_DIR=
$BUILD_DIR
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment