Files
hyperframes/.github/actions/install-ffmpeg-linux/action.yml
T
Miguel Ángel 074de9dd1e ci: install ffmpeg through the GitHub API asset route with a cache (#7401)
* ci: install ffmpeg through the GitHub API asset route with a cache

* ci: the three jobs without a prepared ffmpeg stop downloading ffmpeg-static from releases

* ci: the ffmpeg install failure message counts its three downloads
2026-11-08 11:31:54 +00:00

62 lines
2.4 KiB
YAML

name: Install ffmpeg (Linux)
description: >-
Put a pinned static ffmpeg and ffprobe from BtbN/FFmpeg-Builds on PATH. No
apt: its mirror has taken up to 10 minutes.
inputs:
release-url:
description: >-
BtbN/FFmpeg-Builds linux64 tarball. Bump the tag, filename and sha256
together, and keep in sync with the Dockerfiles' FFMPEG pins.
required: false
default: https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-02-28-12-59/ffmpeg-n8.0.1-66-g27b8d1a017-linux64-gpl-8.0.tar.xz
sha256:
description: sha256 of the tarball, from the release's checksums.sha256.
required: false
default: 26d2ecd0cefba99f9d1ea92252a3a4f743a58df4c1c3cf9f8bbaaa40b1fca5b0
token:
description: Token for the GitHub API asset route.
required: false
default: ${{ github.token }}
runs:
using: composite
steps:
- name: Restore the ffmpeg tarball
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ${{ runner.temp }}/ffmpeg-archive
key: ffmpeg-linux-${{ inputs.sha256 }}
- name: Install ffmpeg
shell: bash
env:
URL: ${{ inputs.release-url }}
SHA256: ${{ inputs.sha256 }}
GH_TOKEN: ${{ inputs.token }}
run: |
set -euo pipefail
name="${URL##*/}"
repo="$(sed -E 's#^https://github.com/([^/]+/[^/]+)/releases/download/.*#\1#' <<<"$URL")"
tag="$(sed -E 's#^.*/releases/download/([^/]+)/.*#\1#' <<<"$URL")"
dir="$RUNNER_TEMP/ffmpeg-archive"
archive="$dir/$name"
mkdir -p "$dir"
verified() { [ -f "$archive" ] && sha256sum -c --quiet <<<"$SHA256 $archive"; }
# github.com/releases/download answers 504 under load; the API asset route does not.
fetch() {
local id
id="$(gh api "repos/$repo/releases/tags/$tag" --jq ".assets[] | select(.name == \"$name\") | .id")"
gh api -H "Accept: application/octet-stream" "repos/$repo/releases/assets/$id" > "$archive"
}
for attempt in 1 2 3 4; do
verified && break
[ "$attempt" = 4 ] && { echo "ffmpeg download failed three times" >&2; exit 1; }
fetch || sleep $((attempt * 5))
done
bin="$RUNNER_TEMP/ffmpeg-bin"
mkdir -p "$bin"
tar -xJf "$archive" -C "$bin" --strip-components=2 --wildcards '*/bin/ffmpeg' '*/bin/ffprobe'
echo "$bin" >> "$GITHUB_PATH"
"$bin/ffmpeg" -version | head -1