Build FFmpeg 2 #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build FFmpeg 2 | |
on: | |
schedule: | |
- cron: '7 11 * * 0' | |
workflow_dispatch: | |
inputs: | |
force_build: | |
description: Disable checking for newer commit | |
type: boolean | |
no_release: | |
description: Don't create release | |
type: boolean | |
use_own_fork: | |
description: Use own ffmpeg-build-script fork | |
type: boolean | |
watch: | |
types: [started] | |
concurrency: | |
group: ${{ github.workflow }} | |
jobs: | |
check: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Get FFmpeg latest commit | |
id: ffmpeg-info | |
run: | | |
git_sha=$(gh api repos/FFmpeg/FFmpeg/commits/master -q .sha) | |
echo git-sha=$git_sha >> $GITHUB_OUTPUT | |
echo git-sha-short=${git_sha::7} >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_REPO }} | |
- name: Get ${{ inputs.use_own_fork && github.repository_owner || 'xdeadboy666x' }}/ffmpeg-build-script latest commit | |
id: ffmpeg--build-script-info | |
run: | | |
git_owner=${{ inputs.use_own_fork && github.repository_owner || 'xdeadboy666x' }} | |
git_sha=$(gh api repos/$git_owner/ffmpeg-build-script/commits/master -q .sha) | |
echo git-owner=$git_owner >> $GITHUB_OUTPUT | |
echo git-sha=$git_sha >> $GITHUB_OUTPUT | |
echo git-sha-short=${git_sha::7} >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_REPO }} | |
- name: Get ffmpeg-build-script latest build | |
id: ffmpeg-build-script-info | |
run: | | |
tag_name=$(gh api repos/$GITHUB_REPOSITORY/releases/latest -q .tag_name) | |
echo git-sha=${tag_name:17:7} >> $GITHUB_OUTPUT | |
echo ffmpeg-build-script-git-sha=${tag_name:25:7} >> $GITHUB_OUTPUT | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_REPO }} | |
- name: Check if there is newer commit | |
if: '! inputs.force_build' | |
run: > | |
[[ "${{ steps.ffmpeg-info.outputs.git-sha-short }}" != "${{ steps.ffmpeg-build-script-info.outputs.git-sha }}" ]] || | |
[[ "${{ steps.ffmpeg-build-script-info.outputs.git-sha-short }}" != "${{ steps.ffmpeg-build-script-info.outputs.ffmpeg-build-script-git-sha }}" ]] | |
outputs: | |
git-sha: ${{ steps.ffmpeg-info.outputs.git-sha }} | |
git-sha-short: ${{ steps.ffmpeg-info.outputs.git-sha-short }} | |
ffmpeg-build-script-git-owner: ${{ steps.ffmpeg--build-script-info.outputs.git-owner }} | |
ffmpeg-build-script-git-sha: ${{ steps.ffmpeg--build-script-info.outputs.git-sha }} | |
ffmpeg-build-script-git-sha-short: ${{ steps.ffmpeg--build-script-info.outputs.git-sha-short }} | |
build: | |
needs: check | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
os: [win64] | |
steps: | |
- name: Checkout ${{ needs.check.outputs.ffmpeg-build-script-git-owner }}/ffmpeg-build-script | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ needs.check.outputs.ffmpeg-build-script-git-owner }}/ffmpeg-build-script | |
ref: ${{ needs.check.outputs.ffmpeg-build-script-git-sha }} | |
persist-credentials: false | |
- name: Checkout FFmpeg | |
uses: actions/checkout@v4 | |
with: | |
repository: FFmpeg/FFmpeg | |
ref: ${{ needs.check.outputs.git-sha }} | |
persist-credentials: false | |
path: ffmpeg-source | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install pip dependencies | |
run: | | |
pip3 install -r https://raw.githubusercontent.com/xdeadboy666x/ffmpeg-build-script/refs/heads/master/packages.txt --upgrade --user | |
- name: Set up CMake | |
uses: lukka/get-cmake@latest | |
- name: Install dependencies | |
run: sudo apt-get install -y re2c curl | |
- name: Build Meson | |
run: | | |
curl -LSso meson.tar.gz https://github.com/mesonbuild/meson/archive/refs/tags/1.7.0.tar.gz | |
tar -xzf meson.tar.gz | |
cd meson-* | |
sudo python3 setup.py build | |
sudo python3 setup.py install | |
- name: Get current FFmpeg git date | |
id: git-date | |
working-directory: ffmpeg-source | |
run: | | |
echo git-date=$(git log -1 --format=%ci) >> $GITHUB_OUTPUT | |
- name: Get current date & time before build | |
id: date-time-before | |
run: | | |
echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT | |
- name: Cache FFmpeg builds | |
id: cache-ffmpeg | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }} | |
key: FFmpeg-${{ runner.os }}-${{ env.CACHE_KEY }}-${{ needs.check.outputs.ffmpeg-build-script-git-sha-short }} | |
restore-keys: | | |
FFmpeg-${{ runner.os }}-${{ env.CACHE_KEY }}- | |
FFmpeg-${{ runner.os }}- | |
- name: Force use of system Meson/Ninja | |
run: export PATH="/usr/bin:$PATH" | |
- name: Install APT dependencies | |
run: | | |
sudo apt update && sudo apt-get install -y \ | |
pkg-config subversion python-is-python3 libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev \ | |
libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev \ | |
ragel build-essential libass-dev autoconf automake curl texinfo libpulse-dev llvm g++ ed \ | |
bison flex cvs yasm cmake git libqrencode-dev make zlib1g-dev unzip pax nasm \ | |
gperf libunistring-dev libaom-dev libdav1d-dev autogen bzip2 autoconf-archive p7zip-full \ | |
meson clang gettext libpng-dev autotools-dev patch wget xz-utils coreutils libx264-dev \ | |
libx265-dev libfdk-aac-dev libopus-dev cppcheck libgegl-0.4-0 libgoogle-perftools4 \ | |
libacl1-dev libdecor-0-dev libmimalloc-dev libpipewire-0.3-dev libpsl-dev \ | |
librust-jemalloc-sys-dev librust-malloc-buf-dev libsrt-doc libsvtav1-dev \ | |
libsvtav1dec-dev libsvtav1enc-dev libtbbmalloc2 libwayland-dev libcamd2 libccolamd2 \ | |
libcholmod3 libcolamd2 libsuitesparseconfig5 libumfpack5 libamd2 openjdk-21-jdk-headless \ | |
autopoint ccache clang cmake gettext gperf ladspa-sdk libbluray-dev libbs2b-dev \ | |
libcaca-dev libcdio-dev libcdio-paranoia-dev libcdparanoia-dev libchromaprint-dev \ | |
libdav1d-dev libgl1-mesa-dev libglu1-mesa-dev libgme-dev libgsm1-dev libjack-dev \ | |
libmodplug-dev libnghttp2-dev libnghttp3-dev libshine-dev libsmbclient-dev libsnappy-dev \ | |
libspeex-dev libssh-dev libtesseract-dev libtwolame-dev libv4l-dev libvo-amrwbenc-dev \ | |
libvpl-dev libxi-dev libyuv-dev libzvbi-dev valgrind zlib1g-dev liblzma-dev liblz4-dev | |
- name: Compile FFmpeg ${{ needs.check.outputs.git-sha-short }} using ffmpeg-build-script ${{ needs.check.outputs.ffmpeg-build-script-git-sha-short }} | |
run: export TERM=xterm && bash build-ffmpeg.sh --build --enable-gpl-and-non-free --compiler=gcc --jobs $(nproc) | |
- name: Install Wine | |
run: sudo apt-get install -y wine64 | |
- name: Verify FFmpeg binary | |
run: | | |
wine ./ffmpeg-source/ffmpeg.exe -version | |
- name: Get current date & time after build | |
id: date-time-after | |
run: | | |
echo date-time=$(date +'%Y-%m-%d %H:%M') >> $GITHUB_OUTPUT | |
echo date-time-tag=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT | |
- name: Upload FFmpeg binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ffmpeg-${{ matrix.os }} | |
path: | | |
ffmpeg-source/ffmpeg.exe | |
ffmpeg-source/ffprobe.exe | |
ffmpeg-source/ffplay.exe | |
if-no-files-found: error | |
retention-days: ${{ inputs.no_release && '0' || '1' }} | |
outputs: | |
date-time-before: ${{ steps.date-time-before.outputs.date-time }} | |
date-time-after: ${{ steps.date-time-after.outputs.date-time }} | |
date-time-after-tag: ${{ steps.date-time-after.outputs.date-time-tag }} | |
git-date: ${{ steps.git-date.outputs.git-date }} | |
archive: | |
permissions: | |
id-token: write | |
attestations: write | |
needs: [check, build] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
os: [win64] | |
steps: | |
- name: Download FFmpeg binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: ffmpeg-${{ matrix.os }} | |
- name: Create LICENSE | |
run: | | |
echo "This version of ffmpeg has nonfree parts compiled in." >> LICENSE | |
echo "Therefore it is not legally redistributable." >> LICENSE | |
- name: Generate artifact attestation for FFmpeg binaries | |
if: '! inputs.no_release' | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-path: ff*.exe | |
- name: 7-Zip FFmpeg binaries | |
run: 7z a -mx9 ffmpeg-${{ needs.check.outputs.git-sha-short }}-${{ needs.check.outputs.ffmpeg-build-script-git-sha-short }}-${{ matrix.os }}-nonfree.7z ff{mpeg,probe,play}.exe LICENSE | |
- name: Generate artifact attestation for FFmpeg archive | |
if: '! inputs.no_release' | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-path: ffmpeg-${{ needs.check.outputs.git-sha-short }}-${{ needs.check.outputs.ffmpeg-build-script-git-sha-short }}-${{ matrix.os }}-nonfree.7z | |
- name: Upload FFmpeg archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ffmpeg-archive-${{ matrix.os }} | |
path: ffmpeg-${{ needs.check.outputs.git-sha-short }}-${{ needs.check.outputs.ffmpeg-build-script-git-sha-short }}-${{ matrix.os }}-nonfree.7z | |
retention-days: ${{ inputs.no_release && '0' || '1' }} | |
compression-level: 0 | |
release: | |
needs: [check, build, archive] | |
if: '! inputs.no_release' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Download FFmpeg archives | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: ffmpeg-archive-* | |
merge-multiple: true | |
- name: Release FFmpeg archives | |
run: | | |
gh release create "${{ needs.build.outputs.date-time-after-tag }}-${{ needs.check.outputs.git-sha-short }}-${{ needs.check.outputs.ffmpeg-build-script-git-sha-short }}" \ | |
ffmpeg-${{ needs.check.outputs.git-sha-short }}-${{ needs.check.outputs.ffmpeg-build-script-git-sha-short }}-win64-nonfree.7z \ | |
-n "FFmpeg nonfree git-${{ needs.check.outputs.git-sha }} in ${{ needs.build.outputs.git-date }} built on ${{ needs.build.outputs.date-time-after }} started at ${{ needs.build.outputs.date-time-before }} | |
Using ${{ needs.check.outputs.ffmpeg-build-script-git-owner }}/ffmpeg-build-script git-${{ needs.check.outputs.ffmpeg-build-script-git-sha }}" \ | |
-t "${{ needs.build.outputs.date-time-after }} ${{ needs.check.outputs.git-sha-short }}" | |
env: | |
GH_TOKEN: ${{ secrets.TOKEN_REPO }} | |
GH_REPO: ${{ github.repository }} |