Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: ci

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
gofmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.4'
- name: gofmt
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "::error::these files are not gofmt-clean:"; echo "$unformatted"
exit 1
fi

test:
name: test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.4'
- run: go vet ./...
- run: go build ./...
- run: go test -race -timeout 20m ./...

# The parsers read files a tool or a server produced: the corpus in
# testdata/fuzz runs as ordinary tests above, this job also mutates it.
fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.4'
- run: go test -timeout 10m -run XXX -fuzz FuzzParseY4MHeader -fuzztime 30s ./internal/bench
- run: go test -timeout 10m -run XXX -fuzz FuzzParseQuality -fuzztime 30s ./internal/bench
- run: go test -timeout 10m -run XXX -fuzz FuzzParsePaths -fuzztime 30s ./internal/bench
- run: go test -timeout 10m -run XXX -fuzz FuzzMatchedBytes -fuzztime 30s ./internal/bench

# int is 32 bits here: a size converted to int before it is compared wraps
# only on this target.
arch-386:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.4'
- run: GOARCH=386 go vet ./...
- run: GOARCH=386 go test -timeout 20m ./...

vuln:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.4'
- run: go install golang.org/x/vuln/cmd/govulncheck@latest
- run: govulncheck ./...
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ profile.cov
go.work
go.work.sum

# Clips are fetched by URL and checked against their SHA-256, never committed
*.y4m
*.y4m.part
*.part
*.mp4
*.mkv
*.webm
*.ivf

# env file
.env

Expand Down
85 changes: 84 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,85 @@
# vectorbench
Reproducible benchmark: frame-by-frame vectorisation (VTracer) against x264, x265, SVT-AV1 and VP9 at matched PSNR and VMAF

Does vectorising a video frame by frame (VTracer) beat a video codec at the
same quality? `vectorbench` answers it per content class: cartoon, anime,
screen content and natural camera footage. It compares
VTracer with x264, x265, SVT-AV1 and VP9 at matched PSNR and matched VMAF.

It records what it measured, with which tools, on which machine, at which
load. A figure that is interpolated between two encoder settings is marked
`est.`; a figure that is only a bound is marked `<=`; a quality no setting
reached is `n/a`. Nothing is rounded into a measured value.

```
go install github.com/go-avkit/vectorbench/cmd/vectorbench@latest

vectorbench pin --work DIR # fetch the clips, print their SHA-256
vectorbench run --work DIR --frames 24 # measure, write DIR/results.json
vectorbench report DIR/results.json # Markdown tables
```

## Tools

| Tool | Pinned | Install |
|---|---|---|
| VTracer | 0.6.5 (MIT) | `cargo install vtracer --version 0.6.5 --locked` |
| resvg | 0.50.0 (MPL-2.0, rasterises the SVG for scoring) | `cargo install resvg --version 0.50.0 --locked` |
| ffmpeg | any recent build with libx264, libx265, libsvtav1, libvpx-vp9 and **libvmaf** | its version string is stored in the results |

`run` refuses a VTracer or resvg of another version unless
`--allow-unpinned-tools` is given, and then stamps the difference into the
results. ffmpeg is not pinned (distributions differ); its full version line and
the encoder library versions are recorded instead.

## Clips

The manifest (`internal/bench/clips.json`) lists Xiph.org clips by URL and
SHA-256. Clips are **never committed**: `run` fetches the header and the first
24 frames with a Range request, hashes those bytes and refuses a mismatch (a
missing hash is also a refusal). `vectorbench pin` fills the hashes in; the
first pin trusts the server once, so read what it fetched. Classes: cartoon
(`GlassHalf`), anime (`SolLevanteFace`), screen (`Wikipedia`, `Slides1` and the
screen recordings `Debugging` and `MissionControlClip3`) and natural camera
footage (`KristenAndSara`, `in_to_tree` and `crowd_run`, a real 1080p50 clip).

## What is measured

- Size: encoded bytes; for vectors, the SVG bytes and their gzip size.
- Quality: PSNR and VMAF (libvmaf, `n_threads=4`) of the decoded or rasterised
frames against the source frames.
- Time: wall and CPU seconds of each encoder process and of the VTracer process
(sum over frames). The load average is read before the first run and after
the last, and stored. The run **refuses to start above `--max-load` (8)**;
`--load-waiver REASON` overrides it and stamps the reason into the results.
Pin the process to one core (`taskset -c N`) and say so with `--note`.
- Flicker proxy: path churn between consecutive frames, below.

### Flicker proxy

Frame-by-frame vectorisation has no temporal model, so the paths of frame N+1
need not resemble those of frame N. For each consecutive pair, the paths of the
two SVGs are matched one to one, largest first, when their bounding boxes have
an IoU of at least 0.5 and their fill colours differ by at most 32 (Euclidean
RGB). `churn` is the fraction of paths that find no partner
(`1 - 2*matched/(n_prev+n_cur)`); the report also gives the unmatched area and
the mean centre shift of matched pairs. It is a **proxy**: it uses bounding
boxes and fills, not outlines, and says nothing about how visible a change is.
Zero means the structure is stable, not that the picture is.

## Limits

Prefixes of 2 to 24 frames, not whole clips: it measures per-frame cost and
quality, not rate control over a long GOP. Encoders run at fixed CRF settings,
so matched-quality sizes are interpolated (log size against quality) and marked.

## Results

`results/` holds the published results JSON, each with its tool versions,
machine and load. Rendered tables and the discussion are on the docs page
"Vector video vs codecs" of go-avkit/docs.

## Licences

The program is MIT. VTracer is MIT and resvg is MPL-2.0; both are run as
separate programs, never linked or vendored. No GPL tracer source was read or
used.
Loading
Loading