Skip to content

Commit cf9cf11

Browse files
authored
feat: enable --enable-libzimg (#574)
* feat: enable --enable-libzimg * 📄 doc: comment the Dockerfile * ⚙️ conf: modify CI to add zimg-dev * ⚙️ conf: try to install and build from git zimg * ⚙️ fix: git recursive * ⚙️ conf: add zimg version display * ⚙️ conf: change cache name to check if cache was responsible for build failure * ⚙️ conf: change dockerfile to build zimg * ➕ add: missing build script file zimg.sh
1 parent 26f0e48 commit cf9cf11

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

.github/workflows/CI.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout Source Code
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v2
17+
- name: Update pkg-config database
18+
run: sudo ldconfig
1719
- name: Setup Docker Buildx
1820
id: buildx
1921
uses: docker/setup-buildx-action@v2
2022
- name: Cache build
2123
id: cache-build
22-
uses: actions/cache@v3
24+
uses: actions/cache@v2
2325
with:
2426
path: build-cache-st
2527
key: build-cache-st-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
@@ -28,31 +30,30 @@ jobs:
2830
- name: Build ffmpeg-core
2931
run: make prd EXTRA_ARGS="--cache-from=type=local,src=build-cache-st --cache-to=type=local,dest=build-cache-st,mode=max"
3032
- name: Upload core
31-
uses: actions/upload-artifact@v3
33+
uses: actions/upload-artifact@v2
3234
with:
3335
name: ffmpeg-core
3436
path: packages/core/dist/*
3537
build-core-mt:
3638
runs-on: ubuntu-latest
3739
steps:
3840
- name: Checkout Source Code
39-
uses: actions/checkout@v3
41+
uses: actions/checkout@v2
4042
- name: Setup Docker Buildx
4143
id: buildx
4244
uses: docker/setup-buildx-action@v2
4345
- name: Cache build
4446
id: cache-build
45-
uses: actions/cache@v3
47+
uses: actions/cache@v2
4648
with:
4749
path: build-cache-mt
48-
4950
key: build-cache-mt-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
5051
restore-keys: |
5152
build-cache-v1-
5253
- name: Build ffmpet-core-mt
5354
run: make prd-mt EXTRA_ARGS="--cache-from=type=local,src=build-cache-mt --cache-to=type=local,dest=build-cache-mt,mode=max"
5455
- name: Upload core-mt
55-
uses: actions/upload-artifact@v3
56+
uses: actions/upload-artifact@v2
5657
with:
5758
name: ffmpeg-core-mt
5859
path: packages/core-mt/dist/*
@@ -63,31 +64,30 @@ jobs:
6364
- build-core-mt
6465
steps:
6566
- name: Checkout Source Code
66-
uses: actions/checkout@v3
67+
uses: actions/checkout@v2
6768
- name: Download ffmpeg-core
68-
uses: actions/download-artifact@v3
69+
uses: actions/download-artifact@v2
6970
with:
7071
name: ffmpeg-core
7172
path: packages/core/dist
7273
- name: Download ffmpeg-core-mt
73-
uses: actions/download-artifact@v3
74+
uses: actions/download-artifact@v2
7475
with:
7576
name: ffmpeg-core-mt
7677
path: packages/core-mt/dist
7778
- name: Use Node.js 18
78-
uses: actions/setup-node@v3
79+
uses: actions/setup-node@v2
7980
with:
8081
node-version: 18.x
8182
- name: Cache dependencies
8283
id: cache-dependencies
83-
uses: actions/cache@v3
84+
uses: actions/cache@v2
8485
with:
8586
path: node_modules
86-
8787
key: node-modules-${{ hashFiles('package-lock.json') }}
8888
restore-keys: |
8989
node-modules-
9090
- name: Install dependencies
9191
run: npm install
9292
- name: Run tests
93-
run: npm test
93+
run: npm test

Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ ENV FFMPEG_MT=$FFMPEG_MT
2020
RUN apt-get update && \
2121
apt-get install -y pkg-config autoconf automake libtool ragel
2222

23+
# Build zimg
24+
FROM emsdk-base AS zimg-builder
25+
ENV ZIMG_BRANCH=release-3.0.5
26+
RUN apt-get update && apt-get install -y git
27+
RUN git clone --recursive -b $ZIMG_BRANCH https://github.com/sekrit-twc/zimg.git /src
28+
COPY build/zimg.sh /src/build.sh
29+
RUN bash -x /src/build.sh
30+
2331
# Build x264
2432
FROM emsdk-base AS x264-builder
2533
ENV X264_BRANCH=4-cores
@@ -137,8 +145,9 @@ COPY --from=theora-builder $INSTALL_DIR $INSTALL_DIR
137145
COPY --from=vorbis-builder $INSTALL_DIR $INSTALL_DIR
138146
COPY --from=libwebp-builder $INSTALL_DIR $INSTALL_DIR
139147
COPY --from=libass-builder $INSTALL_DIR $INSTALL_DIR
148+
COPY --from=zimg-builder $INSTALL_DIR $INSTALL_DIR
140149

141-
# Build ffmpeg
150+
# Build ffmpeg with --enable-libzimg
142151
FROM ffmpeg-base AS ffmpeg-builder
143152
COPY build/ffmpeg.sh /src/build.sh
144153
RUN bash -x /src/build.sh \
@@ -154,7 +163,8 @@ RUN bash -x /src/build.sh \
154163
--enable-libwebp \
155164
--enable-libfreetype \
156165
--enable-libfribidi \
157-
--enable-libass
166+
--enable-libass \
167+
--enable-libzimg
158168

159169
# Build ffmpeg.wasm
160170
FROM ffmpeg-builder AS ffmpeg-wasm-builder
@@ -178,7 +188,8 @@ ENV FFMPEG_LIBS \
178188
-lfreetype \
179189
-lfribidi \
180190
-lharfbuzz \
181-
-lass
191+
-lass \
192+
-lzimg
182193
RUN mkdir -p /src/dist/umd && bash -x /src/build.sh \
183194
${FFMPEG_LIBS} \
184195
-o dist/umd/ffmpeg-core.js

build/zimg.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
CONF_FLAGS=(
6+
--prefix=$INSTALL_DIR # lib installation directory
7+
--host=x86_64-linux-gnu # use i686 linux host
8+
--disable-shared # build static library
9+
--enable-static # enable static library
10+
--disable-dependency-tracking # speed up one-time build
11+
--disable-simd # disable simd optimization
12+
)
13+
14+
emconfigure ./autogen.sh
15+
16+
emconfigure ./configure "${CONF_FLAGS[@]}"
17+
emmake make install -j

0 commit comments

Comments
 (0)