Nodes/ComfyUI_Light_A_Video/Light_A_Video_Sampler
ComfyUI Node

Light_A_Video_Sampler

The sampler that keeps the light still while the world moves

By smthemex·Created 2 years ago·Updated about a year ago· 88
Light_A_Video_Sampler
  • model
  • images
  • mask_img
  • image
relight_prompta car driving on the street, neon light
inpaint_prompta car driving on the beach, sunset over sea
n_promptbad quality, worse quality
seed0
num_step25
strength0.50
text_guide_scale2
width512
height512
bg_target
mask_repoZhengPeng7/BiRefNet
fps8.0

If Light_A_Video_Loader is the kitchen, this is the chef. Light_A_Video_Sampler takes the pipeline the Loader assembled, your video frames, and a prompt, and returns a relit video where the lighting doesn't flicker as the subject moves. That last bit is the whole reason this pack exists: applying IC-Light frame by frame was always the 2024 failure mode, because every frame re-picked its own lighting and the result strobed. Light-A-Video's "progressive light fusion" is what fixes it, and it fixes it without training anything.

How the "training-free" trick works

The relight pass is classic IC-Light: an img2img run against your relight_prompt (default "a car driving on the street, neon light"), with the light direction baked into the initial latent as a gradient. That's what bg_target does - LEFT, RIGHT, TOP, BOTTOM each build a literal bright-to-dark ramp as the "light source," the IC-Light Lighting Preference moved into video. NONE skips the ramp and just uses noise.

Then the video backbone (AnimateDiff, Wan 2.1, or CogVideoX, whichever the Loader built) runs with a patched self-attention: in the up blocks, each frame's attention gets blended with attention against a mean key/value computed across the batch of frames, mixed by a gamma weight. That shared "global light" token is the fusion - every frame is nudged toward the same lighting answer, which is why the light holds steady while the content changes. Nothing is fine-tuned; it's an inference-time attention edit. Worth knowing: num_inference_steps is really num_step / strength, so if you raise strength you're burning more steps per frame.

The inputs that matter

The model port takes the Loader's MODEL_Light_A_Video output - that's the only thing that plugs into it. images is your source video's frames (the output of a video-decode node, as an IMAGE batch). Then the short list:

  • relight_prompt / n_prompt - what lighting you want (neon, sunset, soft window light) and what to avoid. n_prompt defaults to "bad quality, worse quality".
  • bg_target - the light direction. This is the one setting beginners under-use; it's how you aim the light instead of hoping the prompt does it.
  • strength (default 0.5), num_step (25), text_guide_scale (2) - how aggressively frames get re-drawn, sampler steps, and CFG. Lower strength = closer to your original footage.
  • mask_repo - for inpaint mode, which foreground masker to use. Default ZhengPeng7/BiRefNet downloads on first run; leave it blank and it uses SAM2 (sam2_b.pt auto-downloads); or skip the auto-maskers entirely and feed mask_img yourself.
  • Optional fps (default 8) and width/height for the output frame size.

The output is image (an IMAGE batch of the relit frames) - the node saves nothing, so wire it into a video encoder like VHS or Save Video to get a file.

Install and gotchas

Same pack as the Loader: Manager search "ComfyUI_Light_A_Video", or clone into custom_nodes and pip install -r requirements.txt. Two gotchas stand out. First, resolution is backend-bound: the README prescribes 832x480 for Wan and 720x480 for CogVideoX, and the AnimateDiff path is stuck around 512x512 (real users have hit this wall and complained). Second, Wan needs diffusers from the main branch and a 4090 or better; the T5 encoder alone is enormous.

The README's best tip, for the Wan/Cog backends: keep the prompt that drives the video pass to just the subject - "a bear", not "a bear lit by neon" - because the lighting is controlled by bg_target, and a light-writing prompt fights the latent you just set. And if you're on SAM2 for masks, remember its focus point is dead center, so keep the subject middle-frame. Start at the defaults, then raise num_step if the relight looks washed - higher resolutions and longer clips are a straight VRAM trade on all three backends.

CategoryLight_A_Video

Inputs (15)

NameTypeDefaultDescription
modelMODEL_Light_A_Video
imagesIMAGE
relight_promptSTRINGa car driving on the street, neon light
inpaint_promptSTRINGa car driving on the beach, sunset over sea
n_promptSTRINGbad quality, worse quality
seedINT00–2147483647
num_stepINT251–1024
strengthFLOAT0.500–1
text_guide_scaleINT21–20
widthINT51264–2048
heightINT51264–2048
bg_targetCOMBO5 options: LEFT, NONE, RIGHT, TOP, BOTTOM
mask_repoSTRINGZhengPeng7/BiRefNet
mask_imgoptIMAGE
fpsoptFLOAT8.08–100

Outputs (1)

NameTypeDescription
imageIMAGE