Skip to content

feat(tune): vmafx-tune in Go (Stage 1 — compare subcommand) - #17

Merged
lusoris merged 2 commits into
masterfrom
feat/vmafx-tune-go-stage1
May 28, 2026
Merged

lusoris merged 2 commits into
masterfrom
feat/vmafx-tune-go-stage1

Conversation

@lusoris

@lusoris lusoris commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds cmd/vmafx-tune/ — the Stage-1 Go port of vmaf-tune, installed as vmafx-tune-go alongside the Python binary during the migration
  • Ports the compare subcommand: rate-quality sweep via VMAF-target CRF bisect for libx264 and libx265
  • All other subcommands are stubs that redirect to vmaf-tune <subcommand>; Python tools/vmaf-tune/ is unchanged

New packages

Package Description
pkg/encoder/ Encoder interface + LibX264Encoder / LibX265Encoder (subprocess ffmpeg)
pkg/bisect/ Stateless VMAF-target CRF bisect, score function injectable for unit tests
pkg/report/ EmitJSON (RFC 8259 strict, NaN→null) + EmitMarkdown renderers

JSON output is schema-v1/v2 compatible with the Python compare.py / report.py output.

Test plan

  • go build ./cmd/vmafx-tune — clean build
  • go test ./... -count=1 — all pass (bisect convergence, encoder mock, stub redirect, version flag)
  • go vet ./... — clean
  • vmafx-tune-go compare --reference src.mp4 --codecs libx264 --targets 60 --format json — produces valid RFC 8259 JSON with expected schema shape
  • vmafx-tune-go ladder — exits non-zero, prints redirect to vmaf-tune ladder

Smoke-test reproducer

# Build
go build -o /tmp/vmafx-tune-go ./cmd/vmafx-tune

# Generate synthetic source
ffmpeg -f lavfi -i testsrc=size=320x240:rate=24:duration=2 -pix_fmt yuv420p /tmp/src.y4m

# Run compare (vmaf binary required for scoring; without it the row is ok=false)
/tmp/vmafx-tune-go compare \
  --reference /tmp/src.y4m \
  --codecs libx264 \
  --targets 60 \
  --format json

# Verify stubs redirect
/tmp/vmafx-tune-go ladder; echo "exit $?"

Deliverables checklist

  • Research digest: docs/research/vmafx-tune-go-stage1-2026-05-28.md
  • Decision matrix: ADR-0705 ## Alternatives considered
  • AGENTS.md invariant note: cmd/vmafx-tune/AGENTS.md
  • Reproducer / smoke-test command: see Smoke-test reproducer above
  • changelog.d/added/vmafx-tune-go-stage1.md fragment
  • docs/rebase-notes.md entry: no rebase impact (fork-only new directories)

State / ADR

  • ADR-0705 accepted: docs/adr/0705-vmafx-tune-go-stage1.md
  • docs/state.md: T-VMAFX-TUNE-GO-STAGE1-2026-05-28 row added to Recently closed

Out of scope (Stage 2+)

Hardware encoders (NVENC, QSV, AMF), tune-per-shot, ladder, fast, corpus,
report, HTML rendering, --workers concurrency cap, --score-backend GPU
auto-detection.


ffmpeg-patches impact

no ffmpeg-patches impact: this PR adds a new Go binary under cmd/; it does not
touch any C API surface, public headers, meson_options.txt, or the ffmpeg-patches/
stack.

🤖 Generated with Claude Code

lusoris and others added 2 commits May 28, 2026 13:11
Adds cmd/vmafx-tune/ — the Stage-1 Go port of the vmaf-tune rate-quality
tuning CLI. The binary is installed as `vmafx-tune-go` alongside the Python
binary to avoid collisions during the migration (ADR-0705).

Stage 1 ships one fully-functional subcommand:
- `compare`: rate-quality sweep using a VMAF-target CRF bisect for each
  (codec, target) pair. Supports libx264 and libx265 via subprocess ffmpeg.
  Hardware encoders are Stage-2 scope.

New Go packages:
- pkg/encoder/  Encoder interface + LibX264Encoder / LibX265Encoder
- pkg/bisect/   Stateless VMAF-target bisect (mirrors Python Phase B)
- pkg/report/   JSON (RFC 8259 strict, NaN→null) + Markdown renderers

JSON output is schema-compatible with the Python vmaf-tune compare v1/v2
payload so the existing report.py renderer ingests Go output unchanged.

All other subcommands (tune-per-shot, ladder, fast, corpus, report, ...) are
stubs that print a redirect to `vmaf-tune <subcommand>`. Python
tools/vmaf-tune/ is unchanged.

Deliverables:
- ADR-0705 (docs/adr/0705-vmafx-tune-go-stage1.md)
- Research digest (docs/research/vmafx-tune-go-stage1-2026-05-28.md)
- User docs (docs/usage/vmafx-tune-go.md)
- AGENTS.md invariants (cmd/vmafx-tune/AGENTS.md)
- Changelog fragment (changelog.d/added/vmafx-tune-go-stage1.md)
- Rebase notes + state.md entries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Union all Phase 4a ADR index rows (0701-0706) in numeric order. Union
go.mod/go.sum: merge cobra deps (tune) with gRPC/prometheus deps (server).
Union .gitignore, Makefile, docs/principles.md, docs/rebase-notes.md,
docs/state.md with all Phase 4 foundation + server + rust-sys additions.
@lusoris
lusoris marked this pull request as ready for review May 28, 2026 11:26
@lusoris
lusoris merged commit 7805183 into master May 28, 2026
38 of 72 checks passed
@lusoris
lusoris deleted the feat/vmafx-tune-go-stage1 branch May 28, 2026 11:27
@lusoris lusoris added this to the 1.0.0 — First release milestone Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant