Skip to content

[FEATURE] Export buildVideoFilter and add comprehensive unit tests for the FFmpeg filter chain #632

@Kr1491

Description

@Kr1491

Feature description
buildVideoFilter in src/lib/ffmpeg.ts is the most critical function in the entire application. Every export runs through it — it builds the complete FFmpeg filter chain combining trim, rotate, speed, framing, stabilization, and color adjustments. Despite this, the function is currently private (not exported) and has zero test coverage.

The existing test infrastructure (Vitest) is already set up and working — buildAudioFilter already has a solid test suite in src/lib/tests/ffmpeg.test.ts. buildVideoFilter should have the same treatment.

Problem this solves
Without tests on buildVideoFilter:

  • A wrong filter order silently produces broken or corrupted video output with no warning
  • Edge case combinations (e.g. trim + speed + rotate all at once) are completely unverified
  • Any future changes to the filter chain have no safety net — regressions go undetected
  • FFmpeg filter order matters significantly — wrong order produces different and incorrect results

Proposed solution

  1. Export buildVideoFilter from src/lib/ffmpeg.ts by adding the export keyword
  2. Create src/lib/tests/videoFilter.test.ts with test cases covering:
    • Trim only (trimStart > 0, trimEnd set, both)
    • Each rotation value (90, 180, 270, 0)
    • Speed changes (slow, fast, normal)
    • Framing modes (fit vs crop)
    • Brightness, contrast, saturation adjustments
    • Stabilization flag
    • Combinations of multiple settings together
    • Edge cases (speed=1 should not add setpts filter, rotation=0 should add no filter)

Alternatives considered
Integration testing via full export — not practical since FFmpeg WASM cannot run in a Node/Vitest environment. Unit testing the filter string output directly is the correct approach, same as how buildAudioFilter is already tested.

Additional context
buildAudioFilter is already exported and has 7 well-written tests in src/lib/tests/ffmpeg.test.ts — this issue follows the exact same pattern for the video side. The test infrastructure requires no setup changes.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions