Skip to content

Support FFMPEG for windows (x64, arm64), linux (x64, arm64), macos (x64, arm64), android, ios #20

Support FFMPEG for windows (x64, arm64), linux (x64, arm64), macos (x64, arm64), android, ios

Support FFMPEG for windows (x64, arm64), linux (x64, arm64), macos (x64, arm64), android, ios #20

Workflow file for this run

name: linux
on:
push:
tags:
- "*"
pull_request:
branches: ["main"]
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
opencv-version: [4.10.0]
os:
- { arch: arm64, ffmpeg_arch: arm64 }
- { arch: x64, ffmpeg_arch: amd64 }
env:
COMMON_CMAKE_OPTIONS: |
-DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_BUILD_TYPE=Release \
-DOPENCV_EXTRA_MODULES_PATH="${{ github.workspace }}/opencv_contrib/modules" \
-DCMAKE_POLICY_DEFAULT_CMP0074=NEW \
steps:
- name: setup arm64
if: matrix.os.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install g++-aarch64-linux-gnu
- name: setup x64
if: matrix.os.arch == 'x64'
run: |
sudo apt-get update
sudo apt-get install libgtk-3-dev
- uses: actions/checkout@v4
- name: setup-opencv-source
run: |
git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv.git opencv
git clone -b ${{ matrix.opencv-version }} https://github.com/opencv/opencv_contrib.git opencv_contrib
echo "SOURCE_DIR=${{ github.workspace }}/opencv" >> "$GITHUB_ENV"
echo "PACKAGE_NAME=libopencv-linux-${{ matrix.os.arch }}" >> "$GITHUB_ENV"
echo "OPENCV_SUBDIR=lib/cmake/opencv4" >> "$GITHUB_ENV"
- name: set toolchain
run: |
if [ "${{ matrix.os.arch }}" = "arm64" ]; then
echo "TOOLCHAIN_FILE='-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/aarch64-linux-gnu.toolchain.cmake'" >> "$GITHUB_ENV"
else
echo "TOOLCHAIN_FILE=" >> "$GITHUB_ENV"
fi
- name: setup ffmpeg
run: |
wget -q -O ffmpeg.tar.xz https://sourceforge.net/projects/avbuild/files/linux/ffmpeg-6.1-linux-clang-default.tar.xz
mkdir -p ffmpeg
tar xf ffmpeg.tar.xz -C ffmpeg --strip-components=1
mkdir -p ${{ github.workspace }}/ffmpeg/cmake
cp ${{ github.workspace }}/cmake/ffmpeg-config.cmake ${{ github.workspace }}/ffmpeg/cmake/
echo "FFMPEG_ROOT=${{ github.workspace }}/ffmpeg" >> "$GITHUB_ENV"
- name: build
run: |
cd ${{ env.SOURCE_DIR }}
mkdir build && cd build
cmake ${{ env.COMMON_CMAKE_OPTIONS }} -S .. \
${{ env.TOOLCHAIN_FILE }} \
`cat ${{ github.workspace }}/options.txt` \
-DFFMPEG_DIR="${{ env.FFMPEG_ROOT }}/cmake" \
-DFFMPEG_ARCH=${{ matrix.os.ffmpeg_arch }}
cmake --build . -j $(nproc)
cmake --build . --target install
- name: package
run: |
mkdir ${{ env.PACKAGE_NAME }}
cp -rf ${{ env.SOURCE_DIR }}/build/install/* ${{ env.PACKAGE_NAME }}/
mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg
cp -rf ${{ env.FFMPEG_ROOT }}/include ${{ env.PACKAGE_NAME }}/ffmpeg/
mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/bin
cp -rf ${{ env.FFMPEG_ROOT }}/bin/${{ matrix.os.ffmpeg_arch }} ${{ env.PACKAGE_NAME }}/ffmpeg/bin
mkdir -p ${{ env.PACKAGE_NAME }}/ffmpeg/lib
cp -rf ${{ env.FFMPEG_ROOT }}/lib/${{ matrix.os.ffmpeg_arch }} ${{ env.PACKAGE_NAME }}/ffmpeg/lib
cp -rf ${{ env.FFMPEG_ROOT }}/cmake ${{ env.PACKAGE_NAME }}/ffmpeg/cmake
cp -rf ${{ env.FFMPEG_ROOT }}/Changelog ${{ env.PACKAGE_NAME }}/ffmpeg/Changelog
cp -rf ${{ env.FFMPEG_ROOT }}/config-${{ matrix.os.ffmpeg_arch }}.txt ${{ env.PACKAGE_NAME }}/ffmpeg/config.txt
cp -rf ${{ env.FFMPEG_ROOT }}/COPYING.LGPLv2.1 ${{ env.PACKAGE_NAME }}/ffmpeg/COPYING.LGPLv2.1
cp -rf ${{ env.FFMPEG_ROOT }}/README.txt ${{ env.PACKAGE_NAME }}/ffmpeg/README.txt
cp -rf ${{ env.FFMPEG_ROOT }}/RELEASE_NOTES ${{ env.PACKAGE_NAME }}/ffmpeg/RELEASE_NOTES
tar -C ${{ env.PACKAGE_NAME }} -zcvf ${{ env.PACKAGE_NAME }}.tar.gz .
- name: test
run: |
cd test
mkdir build && cd build
cmake ${{ env.COMMON_CMAKE_OPTIONS }} \
${{ env.TOOLCHAIN_FILE }} \
-DOpenCV_DIR=${{ github.workspace }}/${{ env.PACKAGE_NAME }}/${{ env.OPENCV_SUBDIR }} ..
cmake --build . -j $(nproc)
- name: upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{ env.PACKAGE_NAME }}.tar.gz
- name: release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
prerelease: false
files: |
${{ env.PACKAGE_NAME }}.tar.gz