Skip to content

Commit

Permalink
feat: enable --enable-libzimg (#574)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gabrielstuff authored Oct 9, 2023
1 parent 26f0e48 commit cf9cf11
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
uses: actions/checkout@v2
- name: Update pkg-config database
run: sudo ldconfig
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Cache build
id: cache-build
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: build-cache-st
key: build-cache-st-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
Expand All @@ -28,31 +30,30 @@ jobs:
- name: Build ffmpeg-core
run: make prd EXTRA_ARGS="--cache-from=type=local,src=build-cache-st --cache-to=type=local,dest=build-cache-st,mode=max"
- name: Upload core
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v2
with:
name: ffmpeg-core
path: packages/core/dist/*
build-core-mt:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
uses: actions/checkout@v2
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Cache build
id: cache-build
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: build-cache-mt

key: build-cache-mt-v1-${{ hashFiles('Dockerfile', 'Makefile', 'build/*') }}
restore-keys: |
build-cache-v1-
- name: Build ffmpet-core-mt
run: make prd-mt EXTRA_ARGS="--cache-from=type=local,src=build-cache-mt --cache-to=type=local,dest=build-cache-mt,mode=max"
- name: Upload core-mt
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v2
with:
name: ffmpeg-core-mt
path: packages/core-mt/dist/*
Expand All @@ -63,31 +64,30 @@ jobs:
- build-core-mt
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
uses: actions/checkout@v2
- name: Download ffmpeg-core
uses: actions/download-artifact@v3
uses: actions/download-artifact@v2
with:
name: ffmpeg-core
path: packages/core/dist
- name: Download ffmpeg-core-mt
uses: actions/download-artifact@v3
uses: actions/download-artifact@v2
with:
name: ffmpeg-core-mt
path: packages/core-mt/dist
- name: Use Node.js 18
uses: actions/setup-node@v3
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v3
uses: actions/cache@v2
with:
path: node_modules

key: node-modules-${{ hashFiles('package-lock.json') }}
restore-keys: |
node-modules-
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
run: npm test
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ ENV FFMPEG_MT=$FFMPEG_MT
RUN apt-get update && \
apt-get install -y pkg-config autoconf automake libtool ragel

# Build zimg
FROM emsdk-base AS zimg-builder
ENV ZIMG_BRANCH=release-3.0.5
RUN apt-get update && apt-get install -y git
RUN git clone --recursive -b $ZIMG_BRANCH https://github.com/sekrit-twc/zimg.git /src
COPY build/zimg.sh /src/build.sh
RUN bash -x /src/build.sh

# Build x264
FROM emsdk-base AS x264-builder
ENV X264_BRANCH=4-cores
Expand Down Expand Up @@ -137,8 +145,9 @@ COPY --from=theora-builder $INSTALL_DIR $INSTALL_DIR
COPY --from=vorbis-builder $INSTALL_DIR $INSTALL_DIR
COPY --from=libwebp-builder $INSTALL_DIR $INSTALL_DIR
COPY --from=libass-builder $INSTALL_DIR $INSTALL_DIR
COPY --from=zimg-builder $INSTALL_DIR $INSTALL_DIR

# Build ffmpeg
# Build ffmpeg with --enable-libzimg
FROM ffmpeg-base AS ffmpeg-builder
COPY build/ffmpeg.sh /src/build.sh
RUN bash -x /src/build.sh \
Expand All @@ -154,7 +163,8 @@ RUN bash -x /src/build.sh \
--enable-libwebp \
--enable-libfreetype \
--enable-libfribidi \
--enable-libass
--enable-libass \
--enable-libzimg

# Build ffmpeg.wasm
FROM ffmpeg-builder AS ffmpeg-wasm-builder
Expand All @@ -178,7 +188,8 @@ ENV FFMPEG_LIBS \
-lfreetype \
-lfribidi \
-lharfbuzz \
-lass
-lass \
-lzimg
RUN mkdir -p /src/dist/umd && bash -x /src/build.sh \
${FFMPEG_LIBS} \
-o dist/umd/ffmpeg-core.js
Expand Down
17 changes: 17 additions & 0 deletions build/zimg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -euo pipefail

CONF_FLAGS=(
--prefix=$INSTALL_DIR # lib installation directory
--host=x86_64-linux-gnu # use i686 linux host
--disable-shared # build static library
--enable-static # enable static library
--disable-dependency-tracking # speed up one-time build
--disable-simd # disable simd optimization
)

emconfigure ./autogen.sh

emconfigure ./configure "${CONF_FLAGS[@]}"
emmake make install -j

0 comments on commit cf9cf11

Please sign in to comment.