Spots

Test your video pipeline in CI for free: synthetic fixtures, ffprobe goldens…

TL;DR We'll give a video pipeline a real test suite that runs on every pull request, costs nothing, and stores no video files in git. Fixtures are generated with FFmpeg's lavfi source, outputs are asserted with ffprobe JSON snapshots (not byte comparisons), and webhook handlers are tested by replaying recorded payloads. pytest, FFmpeg 8.1 pinned in GitHub Actions, Python 3.12.

We'll give a video pipeline a real test

We'll give a video pipeline a real test suite that runs on every pull request, costs nothing, and stores no video files in git. Fixtures are generated with FFmpeg's lavfi source, outputs are asserted with ffprobe JSON snapshots (not byte comparisons), and webhook handlers are tested by replaying recorded payloads. pytest, FFmpeg 8.1 pinned in GitHub Actions, Python 3.12.

A tests/ directory for a pipeline that looks

A tests/ directory for a pipeline that looks like most of them: a probe() step, a build_ffmpeg_args() step that picks a ladder, a transcode() step that shells out, and a webhook handler that advances state when the encoder (local or managed) reports back. The four tiers, in order of how often they run: This post builds tiers 2 and 3 in full and shows the skeleton for 1 and 4. 2. The fixture factory (no binaries in git) 🎬

FFmpeg can synthesise a test pattern and a

FFmpeg can synthesise a test pattern and a tone from nothing. A two-second 320x240 clip is a few hundred KB and takes well under a second to make. Now every test can ask for exactly the input it needs:

💡 Tip: testsrc2 produces a pattern with motion

💡 Tip: testsrc2 produces a pattern with motion and text, which is closer to real content than plain colour bars and makes encoder behaviour (keyframes, bitrate) more realistic.

💡 Tip: testsrc2 produces a pattern with motion

💡 Tip: testsrc2 produces a pattern with motion and text, which is closer to real content than plain colour bars and makes encoder behaviour (keyframes, bitrate) more realistic. 3. Tier 1: pure logic, no FFmpeg The refactor that makes everything else possible: keep "decide what to run" separate from "run it". These run in milliseconds and catch a surprising share of real bugs, because ladder logic is where the edge cases live. 4. Tier 2: FFmpeg in the loop, asserted with ffprobe

Encoders are not bit-exact across versions, so never

Encoders are not bit-exact across versions, so never compare output bytes. Probe the output and assert on the properties your pipeline is responsible for. Now the tests. One direct assertion, one golden snapshot. First run creates the golden; later runs diff against it.

⚠️ Note: if a golden ever includes bit_rate

⚠️ Note: if a golden ever includes bit_rate or size, it will break on the next FFmpeg upgrade and someone will delete the test. stable_view() exists to stop that.

⚠️ Note: if a golden ever includes bit_rate

⚠️ Note: if a golden ever includes bit_rate or size, it will break on the next FFmpeg upgrade and someone will delete the test. stable_view() exists to stop that. The keyframe cadence you set with -g 48 is stable across builds and worth asserting too: 5. Tier 3: webhook replay from recorded payloads

The provider is not part of your test

The provider is not part of your test suite. Its payloads are. Capture one real payload per event type once (from a dev environment, with a request logger), strip anything sensitive, and commit the JSON. Field names will differ per provider; the shape of the tests does not.

News

Test your video pipeline in CI for free: synthetic fixtures, ffprobe goldens, and webhook replay with pytest

TL;DR We'll give a video pipeline a real test suite that runs on every pull request, costs nothing, and stores no video files in git.

@spots #dev
Source: Dev.to
See more like this