Skip to content

Commit 4cb0139

Browse files
committed
[build] Use package managers for ffmpeg install
1 parent 4bcce29 commit 4cb0139

File tree

1 file changed

+58
-31
lines changed

1 file changed

+58
-31
lines changed
Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,68 @@
11
name: 'Setup FFmpeg'
2+
description: 'Ensure ffmpeg is available on the runner, using OS package managers as a fallback.'
23
inputs:
34
github-token:
4-
required: true
5+
description: 'Unused; kept for backward compatibility with existing callers.'
6+
required: false
7+
default: ''
58

69
runs:
710
using: 'composite'
811
steps:
9-
- name: Setup FFmpeg (latest)
10-
id: latest
11-
continue-on-error: true
12-
uses: FedericoCarboni/setup-ffmpeg@v3
13-
with:
14-
github-token: ${{ inputs.github-token }}
12+
- name: Check for preinstalled ffmpeg
13+
id: check
14+
shell: bash
15+
run: |
16+
if command -v ffmpeg >/dev/null 2>&1; then
17+
echo "ffmpeg already available at: $(command -v ffmpeg)"
18+
ffmpeg -version | head -n 1
19+
echo "installed=true" >> "$GITHUB_OUTPUT"
20+
else
21+
echo "ffmpeg not found on PATH; will install via package manager."
22+
echo "installed=false" >> "$GITHUB_OUTPUT"
23+
fi
1524
16-
- name: Setup FFmpeg (7.0.0)
17-
if: ${{ steps.latest.outcome == 'failure' }}
18-
id: v7-0-0
19-
continue-on-error: true
20-
uses: FedericoCarboni/setup-ffmpeg@v3
21-
with:
22-
github-token: ${{ inputs.github-token }}
23-
ffmpeg-version: "7.0.0"
25+
- name: Install ffmpeg (Linux)
26+
if: ${{ steps.check.outputs.installed == 'false' && runner.os == 'Linux' }}
27+
shell: bash
28+
run: |
29+
for attempt in 1 2 3; do
30+
echo "apt-get attempt $attempt"
31+
if sudo apt-get update && sudo apt-get install -y ffmpeg; then
32+
exit 0
33+
fi
34+
sleep 10
35+
done
36+
echo "Failed to install ffmpeg via apt-get after 3 attempts" >&2
37+
exit 1
2438
25-
- name: Setup FFmpeg (6.1.1)
26-
if: ${{ steps.v7-0-0.outcome == 'failure' }}
27-
id: v6-1-1
28-
continue-on-error: true
29-
uses: FedericoCarboni/setup-ffmpeg@v3
30-
with:
31-
github-token: ${{ inputs.github-token }}
32-
ffmpeg-version: "6.1.1"
39+
- name: Install ffmpeg (macOS)
40+
if: ${{ steps.check.outputs.installed == 'false' && runner.os == 'macOS' }}
41+
shell: bash
42+
run: |
43+
for attempt in 1 2 3; do
44+
echo "brew attempt $attempt"
45+
if brew install ffmpeg; then
46+
exit 0
47+
fi
48+
sleep 10
49+
done
50+
echo "Failed to install ffmpeg via brew after 3 attempts" >&2
51+
exit 1
3352
34-
# The oldest version we allow falling back to must not have `continue-on-error: true`
35-
- name: Setup FFmpeg (6.1.0)
36-
if: ${{ steps.v6-1-1.outcome == 'failure' }}
37-
id: v6-1-0
38-
uses: FedericoCarboni/setup-ffmpeg@v3
39-
with:
40-
github-token: ${{ inputs.github-token }}
41-
ffmpeg-version: "6.1.0"
53+
- name: Install ffmpeg (Windows)
54+
if: ${{ steps.check.outputs.installed == 'false' && runner.os == 'Windows' }}
55+
shell: pwsh
56+
run: |
57+
for ($attempt = 1; $attempt -le 3; $attempt++) {
58+
Write-Host "choco attempt $attempt"
59+
choco install ffmpeg -y --no-progress
60+
if ($LASTEXITCODE -eq 0) { exit 0 }
61+
Start-Sleep -Seconds 10
62+
}
63+
Write-Error "Failed to install ffmpeg via choco after 3 attempts"
64+
exit 1
65+
66+
- name: Verify ffmpeg
67+
shell: bash
68+
run: ffmpeg -version | head -n 1

0 commit comments

Comments
 (0)