Nodes/ComfyUI_SSBeforeAfterNode/SS Before After Video (Depth Map)
ComfyUI Node

SS Before After Video (Depth Map)

The depth-driven before/after video that looks like a camera move

By SamSeenX·Created about a year ago·Updated 8 months ago· 2
SS Before After Video (Depth Map)
  • before_image
  • after_image
  • depth_map
  • video_path
  • preview_frame
transition_typeback_to_front
fps30
width512
height512
output_path/output/
filename_prefixbefore_after_depth_transition
transition_duration2.0
hold_duration1.0
feather0.10
loop_transitionfalse
easing_methodnone

Same idea as this pack's plain fade/wipe node, one extra input, and a completely different feel. Instead of a flat crossfade, the reveal is driven by a depth map, so the "after" image washes through the scene in depth bands - near stuff first, or background first, or blooming outward from mid-depth. It reads like a miniature parallax reveal, the kind of thing that makes a simple comparison look like it was cut in a video editor. This is the version of the pack that's actually worth showing people.

How it works

The depth map gets resized to your output resolution and normalized to 0–1. The usual depth-estimation convention applies: white is near, black is far. Each frame picks a threshold on that normalized depth and builds a mask:

  • back_to_front - starts with the closest pixels and expands outward through the scene.
  • front_to_back - starts in the far background and creeps toward the camera.
  • middle_out - starts at mid-depth and blooms in both directions.

The mask gets a Gaussian blur (here feather scales roughly as feather × 50 in pixels, unlike the sibling node where it's a fraction of the image width), then before and after are composited through it. After that it's the same pipeline as the basic node: PNG frames rendered to a temp folder, ffmpeg encoding to libx264 H.264 with yuv420p, and the mp4 written to ComfyUI's output folder as filename_prefix_00001.mp4.

Where the depth map comes from - the practical part

This node does not estimate depth. You hand it an IMAGE. Any Depth Anything v2 preprocessor from comfyui_controlnet_aux, a Marigold pass, or a plain MiDaS output will do - the ecosystem defaults (and the KB's pick) is Depth Anything v2 for stills. In practice the chain is: Load Image → depth preprocessor → here. No model files to download for the pack itself; the depth estimator is a separate install if you don't already have one.

The classic trap is orientation. If the reveal goes the "wrong" way - background revealing first when you wanted the foreground - your depth map is inverted relative to what the node expects. Flip it (an Invert Image node, or the preprocessor's invert toggle) and the direction reverses. This is purely a convention mismatch between preprocessor and node, and it's the single most common reason someone fiddles with this for an hour.

The inputs that matter

  • before_image / after_image / depth_map - three IMAGE tensors.
  • transition_type - back_to_front, front_to_back, or middle_out.
  • transition_duration (0.5–10s), hold_duration (0–5s), fps (1–120), width/height (multiples of 8, 512 default), loop_transition, and the same output_path / filename_prefix as the sibling.
  • easing_method - none, ease-in, ease-out, both.

And here's a find from reading the source you won't get from the README: easing_method is a no-op in v1.1.4. It's plumbed through the function signatures but never actually applied - frame progress stays linear no matter what you pick. Don't set it expecting smoother motion; it's a placeholder. Good to know before you burn ten minutes trying to feel the difference.

Outputs are video_path (STRING) and preview_frame (IMAGE), same as the basic node. It's an output node, so it's terminal - the preview is a check, not a wire-in.

Installing it

Same pack, same steps - ComfyUI Manager, search "SS Before After" or ComfyUI_SSBeforeAfterNode, or:

cd ComfyUI/custom_nodes
git clone https://github.com/MrSamSeen/ComfyUI_SSBeforeAfterNode
pip install -r ComfyUI_SSBeforeAfterNode/requirements.txt

Restart ComfyUI. Of the requirements (torch, numpy, Pillow, opencv-python, imageio) you only really gain opencv-python and imageio. And you need ffmpeg on the system PATH - the code checks which ffmpeg, then a local binary in the pack folder, then imageio's bundled one, and throws RuntimeError: ffmpeg not found if all three miss:

# Debian/Ubuntu
sudo apt install ffmpeg
# macOS
brew install ffmpeg
# Windows
winget install ffmpeg

Two more practical notes: the depth map gets stretched to width × height like everything else, so generate it at the same aspect ratio. And if your depth map comes out flat and gray, the reveal is mushy - every pixel crosses the threshold at nearly the same frame - so regenerate with a stronger estimator rather than blaming the node.

It's a one-trick pony, but it's a good trick. Give it a decent depth map and this node punches well above its tiny footprint.

Category👀 SamSeen

Inputs (14)

NameTypeDefaultDescription
before_imageIMAGE
after_imageIMAGE
depth_mapIMAGE
transition_typeCOMBOback_to_front3 options: back_to_front, front_to_back, middle_out
fpsINT301–120
widthINT51264–4096
heightINT51264–4096
output_pathSTRING/output/
filename_prefixSTRINGbefore_after_depth_transition
transition_durationFLOAT2.00.5–10
hold_durationFLOAT1.00–5
featherFLOAT0.100–1
loop_transitionBOOLEANfalse
easing_methodCOMBOnone4 options: none, ease-in, ease-out, both

Outputs (2)

NameTypeDescription
video_pathSTRING
preview_frameIMAGE