name: Build on: workflow_dispatch: inputs: ref: description: 'Branch, Tag or Commit to build' required: false default: 'master' env: X264_VERSION: "0.161.3020" FFNVCODEC_VERSION: "n11.0.10.0" jobs: cc: runs-on: ubuntu-20.04 strategy: max-parallel: 4 matrix: license_version: [ 3, 2 ] license: [ "LGPL", "GPL" ] type: [ "shared" , "static" ] bits: [ 64, 32 ] name: "Windows (${{ matrix.bits }}bit, ${{ matrix.type }}, ${{ matrix.license }}v${{ matrix.license_version}})" steps: - name: "Checkout" uses: actions/checkout@v2 with: ref: "${{ github.event.inputs.ref }}" submodules: "recursive" fetch-depth: 0 - name: "Gather Information" id: data shell: bash run: | # Bitness if [ "${{ matrix.bits }}" == "32" ]; then echo "::set-output name=arch::i686" echo "::set-output name=target_os::mingw32" echo "::set-output name=cross_prefix::i686-w64-mingw32" else echo "::set-output name=arch::x86_64" echo "::set-output name=target_os::mingw64" echo "::set-output name=cross_prefix::x86_64-w64-mingw32" fi # License (GPL vs LGPL, v2 vs v3) if [ "${{ matrix.license }}" == "GPL" ]; then echo "::set-output name=flags_license::--enable-gpl" fi if [ "${{ matrix.license_version }}" == "3" ]; then echo "::set-output name=flags_license_version::--enable-version3" fi # Build Type if [ "${{ matrix.type }}" == "static" ]; then echo "::set-output name=flags_type::--enable-static --disable-shared" else echo "::set-output name=flags_type::--disable-static --enable-shared" fi # Commit echo "::set-output name=commit::$(git rev-parse --short=8 HEAD)" # Version VERSION=$(cat RELEASE) echo "::set-output name=version_major::$(echo ${VERSION} | sed -E 's/([a-z0-9]+)\.([a-z0-9]+)\.([a-z0-9]+)/\1/')" echo "::set-output name=version_minor::$(echo ${VERSION} | sed -E 's/([a-z0-9]+)\.([a-z0-9]+)\.([a-z0-9]+)/\2/')" echo "::set-output name=version_patch::$(echo ${VERSION} | sed -E 's/([a-z0-9]+)\.([a-z0-9]+)\.([a-z0-9]+)/\3/')" - name: "Dependency: Packages" shell: bash run: | sudo apt-get update sudo apt-get install \ build-essential git \ cmake make ninja-build \ pkg-config \ mingw-w64 mingw-w64-tools gcc-mingw-w64 g++-mingw-w64 \ nasm # libx264 (FFmpeg 0.5 and up, arbitrarily limited to 1.0 because I'm lazy) - name: "Dependency: x264 (v${{ env.X264_VERSION }}, GPLv2, shared)" if: ${{ (steps.data.outputs.version_major >= 1) && startsWith(matrix.license, 'GPL') }} id: x264 shell: bash run: | curl -L -o "x264.zip" "https://github.com/Xaymar/x264/releases/download/${X264_VERSION}/x264-${{ matrix.bits }}-shared-GPLv2.zip" sudo 7z x -o/usr/${{ steps.data.outputs.cross_prefix }}/ x264.zip 7z x -o./distrib x264.zip echo "::set-output name=flags::--enable-libx264" # NVIDIA Codec Headers (FFmpeg 3.x and up) - name: "Dependency: NVIDIA Codec Headers (MIT, shared)" if: ${{ steps.data.outputs.version_major >= 3 }} id: ffnvcodec shell: bash run: | git clone --depth 1 --branch ${FFNVCODEC_VERSION} "https://git.videolan.org/git/ffmpeg/nv-codec-headers.git" /tmp/nv-codec-headers pushd "/tmp/nv-codec-headers" > /dev/null make PREFIX=/usr/${{ steps.data.outputs.cross_prefix }} sudo make PREFIX=/usr/${{ steps.data.outputs.cross_prefix }} install popd > /dev/null if (( "${{ steps.data.outputs.version_major }}" >= 4 )); then echo "::set-output name=flags::--enable-ffnvcodec --enable-nvdec --enable-nvenc" elif (( "${{ steps.data.outputs.version_major }}" >= 3 )); then if (( "${{ steps.data.outputs.version_minor }}" >= 2 )); then # 3.2+ has cuda, cuvid, nvenc echo "::set-output name=flags::--enable-cuda --enable-cuvid --enable-nvenc" elif (( "${{ steps.data.outputs.version_minor }}" >= 1 )); then # 3.1 has cuda, nvenc echo "::set-output name=flags::--enable-cuda --enable-nvenc" elif (( "${{ steps.data.outputs.version_minor }}" >= 0 )); then # 3.0 has nvenc echo "::set-output name=flags::--enable-nvenc" fi fi # Configure FFmpeg - name: "Configure" shell: bash run: | export PKG_CONFIG_PATH=/usr/${{ steps.data.outputs.cross_prefix }}/lib/pkgconfig:${PKG_CONFIG_PATH} ./configure \ --arch=${{ steps.data.outputs.arch }} \ --target-os=${{ steps.data.outputs.target_os }} \ --cross-prefix=${{ steps.data.outputs.cross_prefix }}- \ --prefix="${{ github.workspace }}/distrib" \ --pkg-config=pkg-config \ --extra-cflags=-O3 --extra-cflags=-mmmx --extra-cflags=-msse --extra-cflags=-msse2 --extra-cflags=-msse3 --extra-cflags=-mssse3 \ --extra-cflags=-msse4.1 --extra-cflags=-msse4.2 --extra-cflags=-mavx --extra-cflags=-maes --extra-cflags=-mpclmul \ --pkg-config=pkg-config \ ${{ steps.data.outputs.flags_license }} ${{ steps.data.outputs.flags_license_version }} \ ${{ steps.data.outputs.flags_type }} \ ${{ steps.x264.outputs.flags }} \ ${{ steps.ffnvcodec.outputs.flags }} - name: "Compile" shell: bash run: | make -j $(($(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}') * 2)) make install - name: "Upload Artifacts" uses: actions/upload-artifact@v1 with: name: ffmpeg-${{ matrix.bits }}-${{ matrix.type }}-${{ matrix.license }}v${{ matrix.license_version }}-${{ steps.data.outputs.version_major }}.${{ steps.data.outputs.version_minor }}.${{ steps.data.outputs.version_patch }}-${{ steps.data.outputs.commit }} path: distrib