Skip to content

Spike: FFmpeg vs gstreamer-rs binding decision #108

Description

@natashaannn

Context

The native Rust rewrite (RFC 0001) requires a decode/encode binding for the render engine. This decision must be made before any Epic 1 (Native Render Engine) issues are written — the binding choice determines every subsequent API call in the compositor. Deciding mid-epic would force a rewrite of already-written code.

This spike runs in the current repo under spike/rust-decode-spike/ on its own branch. The findings port to the new repo; the spike code does not.

Question to answer

Is a native FFmpeg Rust binding or gstreamer-rs the better foundation for the render engine on the target hardware matrix?

FFmpeg candidate: test ffmpeg-the-third as the primary candidate, not ffmpeg-next. Per community discussion (source), ffmpeg-next is now maintenance-only (upstream compat patches, no meaningful feature work), while ffmpeg-the-third is the actively-developed fork of the same lineage. If ffmpeg-the-third fails the evaluation criteria below, fall back to testing ffmpeg-next or ac-ffmpeg (smaller community, more actively maintained per the same thread) before ruling out the FFmpeg-binding approach entirely.

Target hardware:

  • Mac M2 (VideoToolbox)
  • Mac M3 (VideoToolbox)
  • Windows x64 with NVIDIA GPU (NVENC/NVDEC)

Evaluation criteria

For each candidate binding, test and document:

  1. Hardware codec access — can it reach VideoToolbox on Mac and NVENC/NVDEC on Windows without extra shims or a non-Rust native layer?
  2. Seek/decode accuracy — frame-accurate seek to an arbitrary timestamp on a real .mp4 fixture (required for jump-cut editing; off-by-one-frame seek is a disqualifier)
  3. Build complexity — does it cross-compile cleanly on all three target platforms? Are system dependencies (FFmpeg libs, GStreamer plugins) manageable in CI?
  4. Crate maturity — update frequency, known unsoundness issues, community size
  5. Redistribution/licensing risk (gstreamer-rs only) — do the codec paths needed (H.264/HEVC decode via VideoToolbox/NVDEC) require any GStreamer plugin that bundles proprietary or non-permissively-licensed codec code? Document any constraint that would affect distributing the compiled app.

Spike scope

Write the minimum Rust code needed to answer the criteria above — not a working compositor, just enough to test the decision surface:

  • Decode a frame at an arbitrary timestamp from a real .mp4 file using each candidate
  • Verify the decoded frame is pixel-accurate (compare against a known reference frame extracted with ffprobe/ffmpeg CLI)
  • Confirm hardware codec path is active (VideoToolbox on Mac, NVENC on Windows) — not silently falling back to software
  • Attempt a cross-platform build on Mac and Windows; document any friction
  • For the GStreamer path, confirm which plugins/elements are required for the target codecs and whether any are proprietary/non-open-source

Considered and deferred

  • Shelling out to the FFmpeg CLI instead of binding to it (e.g. via ffmpeg-sidecar) was raised repeatedly in the source discussion as a lower-risk alternative to fighting binding maturity issues. Deferred for this spike: the render engine's jump-cut compositing needs frame-accurate, in-process seek/decode that subprocess piping can't cleanly provide. Worth one line in FINDINGS.md noting this was considered, in case both binding candidates prove too fragile and this needs revisiting.

Output

A findings doc committed to the spike branch at spike/rust-decode-spike/FINDINGS.md containing:

  • Which binding is recommended and why
  • The test results for each evaluation criterion on each platform tested
  • Any caveats or open questions for the Epic 1 implementation
  • The chosen binding becomes the encoderProfile design decision that Epic 1 is built against

Acceptance criteria

  • spike/rust-decode-spike/FINDINGS.md exists and addresses all five evaluation criteria
  • Frame-accurate decode verified on at least one real .mp4 episode fixture on Mac
  • Hardware codec path confirmed active (not software fallback) on at least one Mac target
  • Windows/NVIDIA result documented — even if tested on one machine, not CI
  • A clear recommendation is stated with rationale; no open decision left for Epic 1 to inherit

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions