Skip to content

Commit b6bead1

Browse files
authored
Merge pull request #61 from Zalewa/fix_static
Make an actual static build & allow building in docker & make it closer to Van Sickle's.
2 parents 4926f53 + d99ebd7 commit b6bead1

File tree

6 files changed

+221
-12
lines changed

6 files changed

+221
-12
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin/
2+
build/
3+
dl/
4+
target/

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM ubuntu:16.04
2+
3+
# Basic packages needed to download dependencies and unpack them.
4+
RUN apt-get update && apt-get install -y \
5+
bzip2 \
6+
perl \
7+
tar \
8+
wget \
9+
xz-utils \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Install packages necessary for compilation.
13+
RUN apt-get update && apt-get install -y \
14+
autoconf \
15+
automake \
16+
bash \
17+
build-essential \
18+
cmake \
19+
curl \
20+
frei0r-plugins-dev \
21+
gawk \
22+
libfontconfig-dev \
23+
libfreetype6-dev \
24+
libopencore-amrnb-dev \
25+
libopencore-amrwb-dev \
26+
libsdl1.2-dev \
27+
libspeex-dev \
28+
libssl-dev \
29+
libtheora-dev \
30+
libtool \
31+
libva-dev \
32+
libvdpau-dev \
33+
libvo-amrwbenc-dev \
34+
libvorbis-dev \
35+
libwebp-dev \
36+
libxcb1-dev \
37+
libxcb-shm0-dev \
38+
libxcb-xfixes0-dev \
39+
libxvidcore-dev \
40+
lsb-release \
41+
pkg-config \
42+
sudo \
43+
tar \
44+
texi2html \
45+
yasm \
46+
zlib1g-dev \
47+
&& rm -rf /var/lib/apt/lists/*
48+
49+
# Copy the build scripts.
50+
COPY build.sh download.pl env.source fetchurl /ffmpeg-static/
51+
52+
VOLUME /ffmpeg-static
53+
CMD cd /ffmpeg-static; /bin/bash

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,33 @@ Build dependencies
2222
Build & "install"
2323
-----------------
2424

25-
$ ./build.sh [-j <jobs>] [-B]
25+
$ ./build.sh [-j <jobs>] [-B] [-d]
2626
# ... wait ...
2727
# binaries can be found in ./target/bin/
2828

2929
Ubuntu users can download dependencies and and install in one command:
3030

3131
$ sudo ./build-ubuntu.sh
3232

33-
If you have built ffmpeg before with `build.sh`, the default behaviour is to keep the previous configuration. If you would like to reconfigure and rebuild all packages, use the `-B` flag.
33+
If you have built ffmpeg before with `build.sh`, the default behaviour is to keep the previous configuration. If you would like to reconfigure and rebuild all packages, use the `-B` flag. `-d` flag will only download and unpack the dependencies but not build.
3434

3535
NOTE: If you're going to use the h264 presets, make sure to copy them along the binaries. For ease, you can put them in your home folder like this:
3636

3737
$ mkdir ~/.ffmpeg
3838
$ cp ./target/share/ffmpeg/*.ffpreset ~/.ffmpeg
3939

40+
41+
Build in docker
42+
---------------
43+
44+
$ docker build -t ffmpeg-static .
45+
$ docker run -it ffmpeg-static
46+
$ ./build.sh [-j <jobs>] [-B] [-d]
47+
48+
The binaries will be created in `/ffmpeg-static/bin` directory.
49+
Method of getting them out of the Docker container is up to you.
50+
`/ffmpeg-static` is a Docker volume.
51+
4052
Debug
4153
-----
4254

build-ubuntu.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@ sudo apt-get -y --force-yes install \
66
automake \
77
build-essential \
88
cmake \
9+
frei0r-plugins-dev \
10+
gawk \
911
libass-dev \
1012
libfreetype6-dev \
13+
libopencore-amrnb-dev \
14+
libopencore-amrwb-dev \
1115
libsdl1.2-dev \
16+
libspeex-dev \
17+
libssl-dev \
1218
libtheora-dev \
1319
libtool \
1420
libva-dev \
1521
libvdpau-dev \
22+
libvo-amrwbenc-dev \
1623
libvorbis-dev \
24+
libwebp-dev \
1725
libxcb1-dev \
1826
libxcb-shm0-dev \
1927
libxcb-xfixes0-dev \
28+
libxvidcore-dev \
2029
pkg-config \
2130
texi2html \
2231
zlib1g-dev
@@ -25,7 +34,7 @@ sudo apt-get -y --force-yes install \
2534
# libx265 requires cmake version >= 2.8.8
2635
# 12.04 only have 2.8.7
2736
ubuntu_version=`lsb_release -rs`
28-
need_ppa=`echo $ubuntu_version'<=12.04' | bc -l)`
37+
need_ppa=`echo $ubuntu_version'<=12.04' | bc -l`
2938
if [ $need_ppa -eq 1 ]; then
3039
sudo add-apt-repository ppa:roblib/ppa
3140
sudo apt-get update

build.sh

Lines changed: 135 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ set -u
66
jflag=
77
jval=2
88
rebuild=0
9+
download_only=0
910
uname -mpi | grep -qE 'x86|i386|i686' && is_x86=1 || is_x86=0
1011

11-
while getopts 'j:B' OPTION
12+
while getopts 'j:Bd' OPTION
1213
do
1314
case $OPTION in
1415
j)
@@ -18,8 +19,11 @@ do
1819
B)
1920
rebuild=1
2021
;;
22+
d)
23+
download_only=1
24+
;;
2125
?)
22-
printf "Usage: %s: [-j concurrency_level] (hint: your cores + 20%%) [-B]\n" $(basename $0) >&2
26+
printf "Usage: %s: [-j concurrency_level] (hint: your cores + 20%%) [-B] [-d]\n" $(basename $0) >&2
2327
exit 2
2428
;;
2529
esac
@@ -85,6 +89,25 @@ download \
8589
"nil" \
8690
"https://github.com/mstorsjo/fdk-aac/tarball"
8791

92+
# libass dependency
93+
download \
94+
"harfbuzz-1.4.6.tar.bz2" \
95+
"" \
96+
"e246c08a3bac98e31e731b2a1bf97edf" \
97+
"https://www.freedesktop.org/software/harfbuzz/release/"
98+
99+
download \
100+
"fribidi-0.19.7.tar.bz2" \
101+
"" \
102+
"6c7e7cfdd39c908f7ac619351c1c5c23" \
103+
"https://www.fribidi.org/download/"
104+
105+
download \
106+
"0.13.6.tar.gz" \
107+
"libass-0.13.6.tar.gz" \
108+
"nil" \
109+
"https://github.com/libass/libass/archive/"
110+
88111
download \
89112
"lame-3.99.5.tar.gz" \
90113
"" \
@@ -103,12 +126,46 @@ download \
103126
"b0925c8266e2859311860db5d76d1671" \
104127
"https://github.com/webmproject/libvpx/archive"
105128

129+
download \
130+
"rtmpdump-2.3.tgz" \
131+
"" \
132+
"eb961f31cd55f0acf5aad1a7b900ef59" \
133+
"https://rtmpdump.mplayerhq.hu/download/"
134+
135+
download \
136+
"soxr-0.1.2-Source.tar.xz" \
137+
"" \
138+
"0866fc4320e26f47152798ac000de1c0" \
139+
"https://sourceforge.net/projects/soxr/files/"
140+
141+
download \
142+
"release-0.98b.tar.gz" \
143+
"vid.stab-release-0.98b.tar.gz" \
144+
"299b2f4ccd1b94c274f6d94ed4f1c5b8" \
145+
"https://github.com/georgmartius/vid.stab/archive/"
146+
147+
download \
148+
"release-2.5.1.tar.gz" \
149+
"zimg-release-2.5.1.tar.gz" \
150+
"24afac41d38398bef9ee9a55c6bf1627" \
151+
"https://github.com/sekrit-twc/zimg/archive/"
152+
153+
download \
154+
"v2.1.2.tar.gz" \
155+
"openjpeg-2.1.2.tar.gz" \
156+
"40a7bfdcc66280b3c1402a0eb1a27624" \
157+
"https://github.com/uclouvain/openjpeg/archive/"
158+
106159
download \
107160
"n3.2.4.tar.gz" \
108161
"ffmpeg3.2.4.tar.gz" \
109162
"8ca58121dd042153656d89eba3daa7ab" \
110163
"https://github.com/FFmpeg/FFmpeg/archive"
111164

165+
[ $download_only -eq 1 ] && exit 0
166+
167+
TARGET_DIR_SED=$(echo $TARGET_DIR | awk '{gsub(/\//, "\\/"); print}')
168+
112169
if [ $is_x86 -eq 1 ]; then
113170
echo "*** Building yasm ***"
114171
cd $BUILD_DIR/yasm*
@@ -141,6 +198,28 @@ autoreconf -fiv
141198
make -j $jval
142199
make install
143200

201+
echo "*** Building harfbuzz ***"
202+
cd $BUILD_DIR/harfbuzz-*
203+
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
204+
./configure --prefix=$TARGET_DIR --disable-shared --enable-static
205+
make -j $jval
206+
make install
207+
208+
echo "*** Building fribidi ***"
209+
cd $BUILD_DIR/fribidi-*
210+
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
211+
./configure --prefix=$TARGET_DIR --disable-shared --enable-static
212+
make -j $jval
213+
make install
214+
215+
echo "*** Building libass ***"
216+
cd $BUILD_DIR/libass-*
217+
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
218+
./autogen.sh
219+
./configure --prefix=$TARGET_DIR --disable-shared
220+
make -j $jval
221+
make install
222+
144223
echo "*** Building mp3lame ***"
145224
cd $BUILD_DIR/lame*
146225
# The lame build script does not recognize aarch64, so need to set it manually
@@ -164,12 +243,43 @@ cd $BUILD_DIR/libvpx*
164243
PATH="$BIN_DIR:$PATH" make -j $jval
165244
make install
166245

167-
NPROC=1
168-
if which `nproc`;then
169-
NPROC="`nproc`"
170-
elif [ -f /proc/cpuinfo ];then
171-
NPROC="`grep -c ^processor /proc/cpuinfo`"
172-
fi
246+
echo "*** Building librtmp ***"
247+
cd $BUILD_DIR/rtmpdump-*
248+
cd librtmp
249+
[ $rebuild -eq 1 ] && make distclean || true
250+
sed -i "s/prefix=.*/prefix=${TARGET_DIR_SED}/" ./Makefile # there's no configure
251+
make -j $jval
252+
make install
253+
254+
echo "*** Building libsoxr ***"
255+
cd $BUILD_DIR/soxr-*
256+
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
257+
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DBUILD_SHARED_LIBS:bool=off -DWITH_OPENMP:bool=off -DBUILD_TESTS:bool=off
258+
make -j $jval
259+
make install
260+
261+
echo "*** Building libvidstab ***"
262+
cd $BUILD_DIR/vid.stab-release-*
263+
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
264+
sed -i "s/vidstab SHARED/vidstab STATIC/" ./CMakeLists.txt
265+
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR"
266+
make -j $jval
267+
make install
268+
269+
echo "*** Building openjpeg ***"
270+
cd $BUILD_DIR/openjpeg-*
271+
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
272+
PATH="$BIN_DIR:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$TARGET_DIR" -DBUILD_SHARED_LIBS:bool=off
273+
make -j $jval
274+
make install
275+
276+
echo "*** Building zimg ***"
277+
cd $BUILD_DIR/zimg-release-*
278+
[ $rebuild -eq 1 -a -f Makefile ] && make distclean || true
279+
./autogen.sh
280+
./configure --enable-static --prefix=$TARGET_DIR --disable-shared
281+
make -j $jval
282+
make install
173283

174284
# FFMpeg
175285
echo "*** Building FFmpeg ***"
@@ -181,23 +291,39 @@ PKG_CONFIG_PATH="$TARGET_DIR/lib/pkgconfig" ./configure \
181291
--pkg-config-flags="--static" \
182292
--extra-cflags="-I$TARGET_DIR/include" \
183293
--extra-ldflags="-L$TARGET_DIR/lib" \
294+
--extra-ldexeflags="-static" \
184295
--bindir="$BIN_DIR" \
185296
--enable-pic \
186297
--enable-ffplay \
187298
--enable-ffserver \
299+
--enable-fontconfig \
300+
--enable-frei0r \
188301
--enable-gpl \
302+
--enable-version3 \
189303
--enable-libass \
304+
--enable-libfribidi \
190305
--enable-libfdk-aac \
191306
--enable-libfreetype \
192307
--enable-libmp3lame \
308+
--enable-libopencore-amrnb \
309+
--enable-libopencore-amrwb \
310+
--enable-libopenjpeg \
193311
--enable-libopus \
312+
--enable-librtmp \
313+
--enable-libsoxr \
314+
--enable-libspeex \
194315
--enable-libtheora \
316+
--enable-libvidstab \
317+
--enable-libvo-amrwbenc \
195318
--enable-libvorbis \
196319
--enable-libvpx \
320+
--enable-libwebp \
197321
--enable-libx264 \
198322
--enable-libx265 \
323+
--enable-libxvid \
324+
--enable-libzimg \
199325
--enable-nonfree
200-
PATH="$BIN_DIR:$PATH" make -j$NPROC
326+
PATH="$BIN_DIR:$PATH" make -j $jval
201327
make install
202328
make distclean
203329
hash -r

fetchurl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ if [ "$UNPACK" -ne 0 ]; then
9494
extname=.tgz
9595
elif [ "$filename" != "${filename%.tar.bz2}" ]; then
9696
extname=.tar.bz2
97+
elif [ "$filename" != "${filename%.tar.xz}" ]; then
98+
extname=.tar.xz
9799
else
98100
stderr extension of $filename is not supported
99101
exit 1
@@ -111,6 +113,9 @@ if [ "$UNPACK" -ne 0 ]; then
111113
.tar.bz2)
112114
sh tar "$tarargs" -xjvf "$cache_file"
113115
;;
116+
.tar.xz)
117+
sh tar "$tarargs" -xJvf "$cache_file"
118+
;;
114119
*)
115120
stderr BUG, this should not happen
116121
exit 1

0 commit comments

Comments
 (0)