This file is for AI coding agents and automated contributors working on Mosaic.
Human contributors should start with README.md and CONTRIBUTING.md.
Mosaic is a Go library for ABR encoding to HLS and DASH CMAF.
Core flow:
Job -> probe -> ladder -> optimize -> encoder -> FFmpeg
Do not bypass this flow unless the task explicitly requires it.
For code changes, read:
README.mddocs/ARCHITECTURE.mddocs/ENCODING.mdFor public API changes, also read:
docs/API.mdCONTRIBUTING.mdCHANGELOG.mdmosaic package.exec.Command directly outside internal/executor.executor.CommandExecutor for any FFmpeg or FFprobe behavior.gofmt on changed Go files.Ladders preserve source display aspect ratio.
Do not reintroduce fixed 16:9 output sizing for square, portrait, or non-standard inputs.
Probe and ladder logic use display dimensions, not raw stored dimensions.
When normalization is enabled:
Do not remove output rotation metadata clearing unless replacing it with a tested equivalent.
HLS and DASH encoders create outDir automatically.
Tests should use t.TempDir() rather than root-level paths like /output.
Prefer mock executor tests for command construction.
Use real FFmpeg smoke tests only when necessary and keep generated files under /tmp.
gofmt -w <changed-go-files>
GOCACHE=/tmp/go-build go test ./...
GOCACHE=/tmp/go-build go vet ./...
Optional:
golangci-lint run
Update docs when behavior changes.
Common mappings:
| Change Type | Docs To Update |
|---|---|
| Public API | README.md, docs/API.md, CHANGELOG.md |
| Encode behavior | README.md, docs/ENCODING.md, CHANGELOG.md |
| Package structure | STRUCTURE.md, docs/ARCHITECTURE.md |
| Test workflow | docs/TESTING.md, CONTRIBUTING.md |
| User-facing bug fix | CHANGELOG.md, relevant troubleshooting docs |
git status --short before committing.Square input should produce square rungs:
1080x1080 -> 1080x1080, 720x720, 360x360
Rotated portrait input with stored 1920x1080 and rotation -90 should produce portrait rungs:
608x1080, 404x720, 202x360
Non-standard landscape input 1280x718 should not be forced to 640x360; it should preserve ratio approximately:
642x360
pad back into the filter graph.Width and Height are display dimensions./output.CHANGELOG.md.