-
Notifications
You must be signed in to change notification settings - Fork 875
/
Copy pathDockerfile.ffmpeg-static-alpine
136 lines (110 loc) · 4.33 KB
/
Dockerfile.ffmpeg-static-alpine
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# syntax=docker/dockerfile:1.3
# To build release:
# docker buildx build -f Dockerfile.ffmpeg-static-alpine -t ghcr.io/hybridgroup/ffmpeg:5.16-alpine --platform=linux/arm64,linux/amd64 --load .
# linux/amd64 build
FROM --platform=linux/amd64 alpine:3.20 AS builder-amd64
WORKDIR /
ARG FFMPEG_VERSION=5.1.6
ARG XZ_VERSION=5.6.3
# download xz
RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \
tar -xf xz-${XZ_VERSION}.tar.bz2
# download bzip2
RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \
tar -xf bzip2-master.tar.bz2
# download ffmpeg source
RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \
tar -xf ffmpeg-5.0.tar.bz2
# Install dependencies
RUN apk update && apk add --no-cache \
build-base \
cmake \
git \
diffutils \
perl \
wget \
unzip \
pkgconfig \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
eigen-dev \
nasm yasm \
bzip2 xz zlib-dev x264-dev libvpx-dev \
opus-dev dav1d-dev python3
# Build and install xz
RUN cd xz-${XZ_VERSION} && \
./configure --disable-shared && \
make && make install
# Build and install bzip2
RUN cd bzip2-master && \
mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE="Release" -DENABLE_STATIC_LIB=ON -DENABLE_LIB_ONLY=ON && \
cmake --build . --target install
# Build and install libvpx
RUN cd ffmpeg-${FFMPEG_VERSION} && \
git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
cd libvpx && \
./configure --enable-static --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm && \
make -j $(nproc --all) && make install
# Now finish building ffmpeg
RUN cd ffmpeg-${FFMPEG_VERSION} && \
./configure --pkg-config-flags="--static" \
--enable-static --disable-shared --enable-gpl --enable-libx264 --enable-libvpx --enable-zlib \
--disable-sdl2 --disable-vaapi --disable-vdpau --disable-v4l2-m2m --disable-doc && \
make -j $(nproc --all) && make install
# linux/arm64 build
FROM --platform=linux/arm64 alpine:3.20 AS builder-arm64
WORKDIR /
ARG FFMPEG_VERSION=5.1.6
ARG XZ_VERSION=5.6.3
# download xz
RUN wget -O xz-${XZ_VERSION}.tar.bz2 "https://github.com/tukaani-project/xz/releases/download/v${XZ_VERSION}/xz-${XZ_VERSION}.tar.bz2" && \
tar -xf xz-${XZ_VERSION}.tar.bz2
# download bzip2
RUN wget -O bzip2-master.tar.bz2 "https://gitlab.com/bzip2/bzip2/-/archive/master/bzip2-master.tar.bz2" && \
tar -xf bzip2-master.tar.bz2
# download ffmpeg source
RUN wget -O ffmpeg-5.0.tar.bz2 "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2" && \
tar -xf ffmpeg-5.0.tar.bz2
# Install dependencies
RUN apk update && apk add --no-cache \
build-base \
cmake \
git \
diffutils \
perl \
wget \
unzip \
pkgconfig \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
eigen-dev \
nasm yasm \
bzip2 xz zlib-dev x264-dev libvpx-dev \
opus-dev dav1d-dev python3
# Build and install xz
RUN cd xz-${XZ_VERSION} && \
./configure --disable-shared && \
make && make install
# Build and install bzip2
RUN cd bzip2-master && \
mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE="Release" -DENABLE_STATIC_LIB=ON -DENABLE_LIB_ONLY=ON && \
cmake --build . --target install
# Build and install libvpx
RUN cd ffmpeg-${FFMPEG_VERSION} && \
git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git && \
cd libvpx && \
./configure --enable-static --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm && \
make -j $(nproc --all) && make install
# Now finish building ffmpeg
RUN cd ffmpeg-${FFMPEG_VERSION} && \
./configure --pkg-config-flags="--static" \
--enable-static --disable-shared --enable-gpl --enable-libx264 --enable-libvpx --enable-zlib \
--disable-sdl2 --disable-vaapi --disable-vdpau --disable-v4l2-m2m --disable-doc && \
make -j $(nproc --all) && make install
# Stage 2: Create final image
FROM builder-${TARGETARCH} AS final
CMD ["ffmpeg"]