Custom xfade Expression — effect skill for transitions

For AI agents: find the right skill in one call — curl -s "https://skills.varg.ai/api/search?q=<what the person wants>" returns the matching how-to page and the best skills with install commands, as markdown (Russian works too). Full index: https://skills.varg.ai/llms.txt. Every page has a markdown twin: add .md to its path. Before generating anything, show the person the options on the how-to page.

Write your own transition as a per-pixel expression with xfade=transition=custom:expr=…

What it does

Anything you can describe per pixel from A, B, X, Y and progress P: a checkerboard, a diagonal band, a noise threshold.

When: When none of the 50+ named transitions fits and you still want a one-pass FFmpeg render.

Watch out: Slow renders on long clips: the expression runs for every pixel of every frame of the overlap.

Timing: As designed.

Also called: xfade expr

In FFmpeg

Both inputs need the same size, frame rate, timebase, SAR and pixel format (settb=AVTB fixes the timebase error that fps alone leaves). offset is where the transition starts on the first clip's timeline (its length minus the overlap).

ffmpeg -i a.mp4 -i b.mp4 -filter_complex \
 "[0:v]fps=30,scale=1920:1080,setsar=1,settb=AVTB,format=yuv420p[a];[1:v]fps=30,scale=1920:1080,setsar=1,settb=AVTB,format=yuv420p[b];\
  [a][b]xfade=transition=custom:duration=0.5:offset=4.5[v];[0:a][1:a]acrossfade=d=0.5[a]" \
 -map "[v]" -map "[a]" out.mp4

Custom: replace transition=… with an expression. P runs from 1 to 0 across the overlap; A and B are the two pixel values.

# vertical bands that flip at different times
xfade=transition=custom:duration=0.8:offset=4.2:expr='if(gt(P, mod(floor(X/(W/8)),2)*0.5+0.25), A, B)'

Where this comes from

Use when

Not for

Install

Example output

https://s3.varg.ai/how-to/previews/45a4fa983b36/take-xfade-custom-expr.mp4 — custom between two shots, with the timeline strip of the edit. Footage: Sprite Fright (2021), Blender Studio | studio.blender.org, CC BY 4.0; WING IT! (2023), Blender Studio | studio.blender.org, CC BY 4.0. (credit: Rendered by varg · Sprite Fright (2021) + WING IT! (2023))

More transitions skills