From cf9cf11c6db6741339ceec39657fa9079b69d9f4 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 9 Oct 2023 15:50:34 +0200 Subject: [PATCH] feat: enable --enable-libzimg (#574) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- .github/workflows/CI.yml | 28 ++++++++++++++-------------- Dockerfile | 17 ++++++++++++++--- build/zimg.sh | 17 +++++++++++++++++ 3 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 build/zimg.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5417a20..e470157 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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/*') }} @@ -28,7 +30,7 @@ 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/* @@ -36,23 +38,22 @@ jobs: 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/* @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 09b4657..ff46b9f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 \ @@ -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 @@ -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 diff --git a/build/zimg.sh b/build/zimg.sh new file mode 100644 index 0000000..3ba768e --- /dev/null +++ b/build/zimg.sh @@ -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 \ No newline at end of file