Skip to content

Commit

Permalink
Fix video encoding in wheel builds
Browse files Browse the repository at this point in the history
Version of ffmpeg available for redhat/almalinux based manylinux_2_28
image links to libpython6, this breaks the wheels so we have to build
our own ffmpeg, building a minimal version and uploading to the release
in the publish step, then the wheel deploy jobs can use this.
Also switching to packaged version of libOSMesa instead of building our
own.
  • Loading branch information
OKaluza committed Nov 30, 2023
1 parent f728fc0 commit 860c903
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/osmesa_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: ${{ matrix.os }}
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_SKIP: cp*-win32 *-manylinux_i686 *-musllinux_*
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* cp312-*
CIBW_ENVIRONMENT: LV_PACKAGE=lavavu-osmesa LV_OSMESA=1 LV_LIB_DIRS=/usr/local/lib64
CIBW_BEFORE_BUILD_LINUX: dnf config-manager --set-enabled powertools && dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm -y && dnf install --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm -y && dnf install -y almalinux-release-devel ffmpeg ffmpeg-devel libtiff-devel python3-mako patchelf unzip ninja-build && dnf builddep -y mesa && dnf remove -y meson && pip3 install meson -U && curl -kLO https://archive.mesa3d.org/mesa-23.1.9.tar.xz && tar xf mesa-23.1.9.tar.xz && rm -f mesa-23.1.9.tar.xz && cd mesa-23.1.9/ && python3 -m mesonbuild.mesonmain build/ --buildtype=release -Dosmesa=true -Dgallium-drivers=swrast -Dvulkan-drivers= -Degl=false -Dgbm=false -Dgles1=false -Dgles2=false && ninja -C build/ -j $(nproc) && ninja -C build/ install || true
CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-*
CIBW_ENVIRONMENT: LV_PACKAGE=lavavu-osmesa LV_OSMESA=1 LV_LIB_DIRS=/usr/local/lib64:/usr/lib64:${HOME}/lib LV_INC_DIRS=${HOME}/include
CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y libtiff-devel mesa-libOSMesa-devel
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} {wheel}"
#CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} {wheel}"
#CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} {wheel} && python patchwheel.py {dest_dir}"
strategy:
matrix:
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# - Creates a release on matching tag push
# - builds latest minimal ffmpeg for wheels
# - builds new emscripten wasm
# - uploads release assets
# - updates lavavu.github.io repo
Expand Down Expand Up @@ -79,3 +80,85 @@ jobs:
git tag ${{ steps.get_version.outputs.VERSION }}
git push origin --tags
ffmpeg:
# https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux_2_28_x86_64
steps:
- name: Install deps
run: |
dnf install -y autoconf automake bzip2 bzip2-devel cmake freetype-devel gcc gcc-c++ git libtool make pkgconfig zlib-devel zip
- name: Build nasm
run: |
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O -L https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2
tar xjvf nasm-2.15.05.tar.bz2
cd nasm-2.15.05
./autogen.sh
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make -j$(nproc)
make install
- name: Build yasm
run: |
cd ~/ffmpeg_sources
curl -O -L https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make -j$(nproc)
make install
- name: Build x264
run: |
cd ~/ffmpeg_sources
git clone --branch stable --depth 1 https://code.videolan.org/videolan/x264.git
cd x264
export PATH="$HOME/bin:$PATH"
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-shared
make -j$(nproc)
make install
- name: Build x265
run: |
cd ~/ffmpeg_sources
git clone --branch stable --depth 2 https://bitbucket.org/multicoreware/x265_git
cd x265_git/build/linux
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
make -j$(nproc)
make install
- name: Build ffmpeg
run: |
cd ~/ffmpeg_sources/
curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg
export PATH="$HOME/bin:$PATH"
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --pkg-config-flags="--static" --extra-cflags="-I$HOME/ffmpeg_build/include -fPIC -m64" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --extra-libs=-lpthread --extra-libs=-lm --bindir="$HOME/bin" --enable-gpl --enable-libfreetype --enable-libx264 --enable-libx265 --enable-nonfree --enable-shared --enable-pic --extra-ldexeflags=-pie
make -j$(nproc)
make install
- name: Zip
run: |
cd ~/ffmpeg_build/; rm -rf lib/*.a; zip --symlinks -r /ffmpeg-mini lib/* include/*
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ffmpeg-mini
path: /ffmpeg-mini.zip

ffmpeg-upload:
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: ffmpeg-mini

- name: Upload ffmpeg build to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ffmpeg-mini.zip
asset_name: ffmpeg-mini.zip
tag: ${{ github.ref }}


5 changes: 3 additions & 2 deletions .github/workflows/wheel_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:
env:
CIBW_BUILD_VERBOSITY: 3
CIBW_SKIP: cp*-win32 *-musllinux_* *-manylinux_i686
CIBW_BUILD: cp37-* cp38-* cp39-* cp310-* cp311-* cp312-*
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-*
#CIBW_TEST_COMMAND: python3 -m doctest -v lavavu/lavavu.py
CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel}
CIBW_BEFORE_BUILD_LINUX: dnf config-manager --set-enabled powertools && dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm -y && dnf install --nogpgcheck https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm -y && dnf install -y ffmpeg libtiff-devel
CIBW_ENVIRONMENT: LV_LIB_DIRS=${HOME}/lib LV_INC_DIRS=${HOME}/include
CIBW_BEFORE_BUILD_LINUX: cd ~ && curl -O -L https://github.com/lavavu/LavaVu/releases/latest/download/ffmpeg-mini.zip && unzip -o ffmpeg-mini.zip && dnf install -y libtiff-devel
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
strategy:
matrix:
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ def check_libraries(libraries, headers, extra_lib_dirs=[], extra_inc_dirs=[]):
defines += [('HAVE_LIBTIFF', 1)]
libs += ['tiff']

inc_dirs += ['/usr/include/ffmpeg'] #Required for centos/redhat ffmpeg-devel
if (find_library('avcodec') and find_library('avformat') and find_library('avutil')
and check_libraries(['avcodec', 'avformat', 'avutil'],
['libavformat/avformat.h', 'libavcodec/avcodec.h', 'libavutil/mathematics.h',
Expand Down

0 comments on commit 860c903

Please sign in to comment.