Skip to content

Commit e8b72a3

Browse files
committed
feat(lib): add automatic FFmpeg library download mechanism
- Implement download-lib command to fetch FFmpeg libraries for current platform - Create lib/fetch.go with download, checksum verification, and extraction functionality - Add comprehensive documentation in README.md and docs/DEVELOPMENT.md - Update GitHub workflow to include library download step - Streamline CGO flags for consistent linking across platforms - Modify .gitignore to handle library files correctly - Add "just download-lib" command for manual library downloads
1 parent 741abae commit e8b72a3

10 files changed

Lines changed: 788 additions & 103 deletions

File tree

.github/workflows/go.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ jobs:
2929
fail-fast: false
3030

3131
steps:
32-
- name: Checkout code
33-
uses: actions/checkout@v6
32+
- uses: actions/checkout@v6
3433

35-
- name: Set up Go
36-
uses: actions/setup-go@v6
34+
- uses: actions/setup-go@v6
3735
with:
3836
go-version: '1.24'
37+
cache: true
3938

4039
- name: Install libclang for generator
4140
run: |
@@ -46,6 +45,9 @@ jobs:
4645
brew install llvm
4746
fi
4847
48+
- name: Download FFmpeg libraries
49+
run: go run ./cmd/download-lib/
50+
4951
- name: Run generator
5052
run: go run ./internal/generator
5153
continue-on-error: true

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ coverage.html
3636
result
3737
result-*
3838

39-
lib/linux_amd64/*.a
39+
# FFmpeg static libraries
40+
lib/*/
41+
!lib/fetch.go
42+
!lib/README.md

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,52 @@ Build once, deploy anywhere. No hunting for system FFmpeg. No version mismatches
2222

2323
*Hard fork of the excellent [csnewman/ffmpeg-go](https://github.com/csnewman/ffmpeg-go), modernised with FFmpeg 8.0, Go 1.24, hardware acceleration and a 99.5% smaller git history.*
2424

25+
## Installation
26+
27+
ffmpeg-statigo includes large static libraries (~100MB per platform) that cannot be distributed via `go get`. This requires a simple manual setup:
28+
29+
### Using Git Submodules
30+
31+
For clean project integration, use ffmpeg-statigo as a git submodule:
32+
33+
1. Add ffmpeg-statigo as a submodule in your project
34+
```bash
35+
git submodule add https://github.com/linuxmatters/ffmpeg-statigo vendor/ffmpeg-statigo
36+
```
37+
38+
2. Add a replace directive pointing to the submodule
39+
```bash
40+
go mod edit -replace github.com/linuxmatters/ffmpeg-statigo=./vendor/ffmpeg-statigo
41+
```
42+
43+
3. Get the dependency
44+
```bash
45+
go get github.com/linuxmatters/ffmpeg-statigo
46+
```
47+
48+
4. Download the static libraries
49+
```bash
50+
cd vendor/ffmpeg-statigo
51+
go run ./cmd/download-lib
52+
cd ../..
53+
```
54+
55+
5. Build your project
56+
```bash
57+
go build
58+
```
59+
60+
6. Commit only the submodule reference
61+
62+
The static libraries (`lib/*/libffmpeg.a`) won't be committed - they're gitignored
63+
64+
```bash
65+
git add .gitmodules vendor/ffmpeg-statigo
66+
git commit -m "Add ffmpeg-statigo as submodule"
67+
```
68+
69+
**See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for alternative installation methods, CI/CD integration, and troubleshooting.**
70+
2571
## Codec Inclusion Policy
2672

2773
ffmpeg-statigo provides a **curated FFmpeg static library** focused on the core strengths of FFmpeg: **decoding, processing, and encoding** audio and video streams. ffmpeg-statigo is designed for **Go developers building modern streaming applications**. The pattern is:

cmd/download-lib/main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// download-lib is a utility to download the FFmpeg static libraries
2+
// Run this program to trigger the automatic download and SHA256 verification
3+
package main
4+
5+
import (
6+
"fmt"
7+
"os"
8+
"runtime"
9+
10+
"github.com/linuxmatters/ffmpeg-statigo/lib"
11+
)
12+
13+
func main() {
14+
fmt.Printf("Downloading FFmpeg libraries for %s/%s...\n", runtime.GOOS, runtime.GOARCH)
15+
16+
if err := lib.DownloadLibs(); err != nil {
17+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
18+
os.Exit(1)
19+
}
20+
21+
fmt.Println("Download complete!")
22+
}

0 commit comments

Comments
 (0)