コンテンツへスキップ
Artlintからのメモ

Fix the Flaw, Keep the Clip: Building an AI Video Repair Pipeline

A localized error does not always require regenerating an entire AI-generated video. A repair pipeline can use a vision-language model to identify the defect, tracking and segmentation to define the affected region, and video inpainting to generate a replacement. The engineering challenge is preserving everything that already works. This article explains how to build that pipeline, handle missing objects and temporal boundaries, and evaluate whether a repair actually improves the clip.

An eight-second video can contain seven and a half seconds of footage worth keeping.

Consider a generated scene in which someone reaches across a table. The camera moves smoothly, the background remains stable, and a blue cup sits beside the person’s hand. Three seconds into the clip, the cup disappears. Half a second later, it returns.

The obvious response is to generate another version. That also gives the generator another opportunity to change the person, the lighting, the composition, or the camera movement.

A more controlled approach is to repair the affected part of the existing clip.

AI video repair combines error detection, spatial and temporal localization, video editing, and verification. A vision-language model, or VLM, can help identify and explain the problem. A separate editing model generates replacement content. The system then checks whether the change fixed the original defect while preserving the rest of the footage.

The following design shows how those components can fit together. The disappearing cup will serve as a running example.

Why a convincing frame can still make a bad repair

Replacing a flawed image region is already difficult. Replacing that region across a moving sequence adds another set of constraints.

The repaired object needs to maintain its identity over time. Its position must agree with camera movement. Its motion must connect to the frames before and after the edit. If another object passes in front of it, the correct parts should become hidden.

Independent image edits can produce inconsistent results across a video, even when each processed frame looks acceptable. Research on temporal consistency addresses this problem by connecting appearance across time while preserving the intended image transformation.

For the cup, several superficially successful repairs would still fail:

  • The cup returns, but its handle changes sides between frames.
  • It stays visible while the camera moves, but slides across the table.
  • It appears in front of a hand that should occlude it.
  • Its shadow remains missing.
  • Its position jumps when playback reaches the first unedited frame.

These are different failure modes. A single instruction such as “fix the missing cup” does not define how to prevent them.

The repair needs a specification that describes both the required change and the constraints that must survive it.

Give each component a specific job

A practical pipeline can separate the work into five stages.

Stage

Main responsibility

Output

Detection

Identify a suspected defect and its visible evidence

Defect description and candidate timestamps

Localization

Determine the affected interval and spatial region

Frame references, object tracks, and candidate masks

Repair planning

Define the intended correction and protected content

An executable repair specification

Generation

Produce replacement content using the specification

One or more candidate repairs

Verification

Check correction, preservation, and continuity

Acceptance, rejection, or a request for review

This separation helps diagnose failures.

If the wrong object changes, the problem may be localization. If the mask is correct but the cup becomes a bowl, the editing stage failed. If a visibly flawed candidate is accepted, the verification stage needs attention.

A VLM can contribute to several stages, particularly detection, planning, and semantic verification. Its description alone does not provide a reliable sequence of pixel masks, and an ordinary text response does not modify the video. Those operations require additional components.

1. Confirm the defect before trying to repair it

The first question is whether the suspicious event is actually an error.

A cup can disappear because a hand covers it, because the camera moves away, or because the scene contains an intentional cut. A model that overlooks those explanations could damage valid footage by trying to correct it.

Video-language models can also hallucinate objects, relationships, and temporal details. Research evaluating these failures gives a concrete reason to require evidence before an automatic edit begins.

For the cup example, the detector should identify:

  • The last frame in which the cup is visibly present.
  • The interval in which it is unexpectedly absent.
  • The first frame in which it returns.
  • Whether an occluder, camera movement, or scene transition explains the absence.
  • Whether the original prompt or intended visual style permits the event.

The model’s explanation should distinguish observation from interpretation.

“The cup is absent from these frames” is an observation that can be checked. “The cup violates object permanence” is an interpretation that depends on context.

Use sparse sampling to find candidates, then inspect densely

A first pass can sample the clip to identify suspicious intervals. Once the system finds a candidate, it should inspect the original frames around that event at a higher temporal resolution.

Sampling one frame per second cannot reliably establish what happened during a half-second disappearance. It may miss the event entirely or skip the evidence that explains it.

Keep the mapping between sampled inputs and the source video. Each sampled frame should retain its original presentation timestamp, frame identifier, and any resizing or cropping transform.

A repair applied to the wrong twelve frames is still a failed repair, even if the generated content looks excellent.

2. Turn the finding into a repair specification

A useful repair specification tells the rest of the system what may change, what must remain stable, and how success will be assessed.

For an illustrative clip recorded at a constant 24 frames per second, a disappearance from 3.0 seconds up to, but not including, 3.5 seconds covers twelve frames. Using zero-based indexing, those are frames 72 through 83.

An initial record could look like this:

{
  "clip_id": "clip_017",
  "defect_type": "object_disappearance",
  "target": "blue cup on the table",
  "edit_interval_ms": {
    "start": 3000,
    "end_exclusive": 3500
  },
  "context_interval_ms": {
    "start": 2500,
    "end_exclusive": 4000
  },
  "evidence_frames": [71, 72, 83, 84],
  "required_change": "Restore the cup where it should remain visible.",
  "preserve": [
    "cup identity",
    "camera movement",
    "background outside the approved edit region"
  ],
  "mask_status": "not_created"
}

The distinction between the edit interval and the context interval matters.

The editor may need earlier and later frames to understand the cup’s appearance and the camera’s motion. Providing those frames as context does not automatically authorize changes to them.

The same principle applies spatially. The editor may need to see the entire table and person while changing only a small region.

For variable-frame-rate footage, use the original presentation timestamps to select frames. Multiplying seconds by a nominal frame rate can produce an incorrect mapping.

The specification should also retain the original generation prompt and any reference images. A correction that produces a realistic cup but ignores a required color or shape has not fulfilled the task.

3. Build a mask that follows the repair

A temporal interval says when to edit. A mask says where.

For each frame, define a binary edit mask:

  • A value of 1 permits replacement.
  • A value of 0 protects the original content.

The mask convention should be explicit because different editing interfaces may interpret mask values differently.

When the defective object is visible

If the cup is present but distorted, a segmentation model can identify its visible region. A video segmentation or tracking component can then propagate that selection across the relevant frames.

Promptable video segmentation research supports selecting objects with points, boxes, or masks and refining predictions on additional frames. It also documents difficulties around shot changes, long occlusions, similar objects, and thin or fast-moving details.

That makes propagation a useful starting point, followed by checks around difficult frames.

Overlay the masks on the video and inspect whether they:

  • Remain attached to the intended object.
  • Follow changes in scale and position.
  • Respect foreground occlusion.
  • Avoid absorbing nearby objects.
  • Cover the complete defective region.

When the object has disappeared

A missing object creates a different problem: there may be nothing to segment in the faulty frames.

A tracker’s prediction can help estimate where the cup should be, but that prediction is an inference. It is not a measured object boundary.

The system can use the last reliable observation, the first reliable observation after the gap, and the surrounding camera motion to propose an editable region. A cup fixed to a table provides different motion constraints from a cup being carried through the scene.

If those observations do not sufficiently constrain the missing interval, the system should retain that uncertainty. A confident-looking mask does not make an ambiguous trajectory correct.

Include the consequences of the edit

The object’s visible outline is not always the complete repair region.

Adding the cup may also require restoring its shadow or reflection. Correcting a hand that intersects the cup may require changing part of both objects.

A mask that is too tight can force the editor to create incompatible boundaries. A mask that is too broad exposes more usable content to change.

Choose the region according to the correction and its visible consequences. If the repair requires a larger region than originally planned, update the specification before generating another candidate.

4. Choose the editing method according to the defect

Different defects require different forms of reconstruction.

If suitable visual information exists in neighboring frames, motion-guided propagation may transfer that information into the damaged region. Optical flow estimates correspondence between frames, but errors in that estimate can misalign the propagated content. Video inpainting research combines propagation with learned features and temporal processing to address these limitations.

If the missing content cannot be recovered from the available observations, a generative editor must synthesize it. Research on generative video inpainting explicitly addresses the competing demands of generating foreground content, preserving the surrounding scene, and maintaining identity over time.

For a repair system, that suggests several possible routes:

Defect

Candidate approach

Main concern

A brief damaged region with reliable neighboring observations

Motion-guided reconstruction or propagation

Incorrect correspondence

A missing or malformed object requiring new content

Generative video inpainting

Identity and interaction consistency

A wrong trajectory affecting an entire interaction

Editing a longer action interval

Preserving incompatible motion

A scene that fundamentally fails the prompt

Broader editing or full regeneration

Local changes cannot satisfy the intended scene

For the disappearing cup, the editor should receive the relevant video context, the approved mask sequence, the intended correction, and any supported reference information.

Additional controls such as reference images, pose, depth, or trajectories depend on the editor’s capabilities. They should not be assumed to work through a text prompt alone.

A useful instruction describes the desired state:

Keep the same blue cup resting on the table throughout the editable interval. Match its appearance and position to the surrounding reference frames, and preserve correct occlusion by the person’s hand.

That gives the editor more useful constraints than simply saying that the previous result was wrong.

5. Enforce preservation when assembling the output

Providing the original video as context is not the same as guaranteeing that its pixels will survive unchanged.

A candidate may contain small shifts in color, texture, or geometry outside the intended region. If preservation is a requirement, enforce it when assembling the output.

Let:

  • X_t(p) be the original RGB pixel at position p in frame t.
  • Y_candidate_t(p) be the generated candidate pixel.
  • M_t(p) be the approved binary edit mask.
  • A_t(p) be the blending weight.

Require:

0 <= A_t(p) <= M_t(p)

Then construct the working frame as:

Y_t(p) = (1 - A_t(p)) * X_t(p) + A_t(p) * Y_candidate_t(p)

Here, Y_t(p) is the resulting pixel in the working frame.

Where the mask is zero, the blending weight must also be zero. The original pixel is therefore retained.

Any feathered transition must remain inside the approved edit region. Blurring the mask beyond that region silently expands the area that can change.

This guarantee applies to aligned working frames in the same representation. Lossy encoding, color conversion, resizing, or chroma subsampling can subsequently change pixels in the delivered file. Check preservation before encoding and measure the final encoded result separately.

A clean composite can still contain a bad seam

Compositing protects the surrounding pixels, but the replacement must agree with them.

A cup with the wrong perspective can have a perfectly clean outline. A repaired hand can meet the original wrist at the wrong angle. Blending incompatible object positions can create ghosting.

Inspect the spatial boundary and the transition into and out of the edited interval. If those transitions fail, revise the candidate or the approved repair region.

6. Verify the result at three different scales

A repair needs checks for the target defect, the surrounding content, and the complete sequence.

Video evaluation research already separates dimensions such as subject consistency, motion smoothness, temporal flickering, and spatial relationships. That separation is useful here because improvement on one dimension can hide deterioration on another.

Check the target defect

For the cup, presence alone is insufficient.

The verification questions should include:

  • Does the cup remain visible whenever it should be visible?
  • Does it retain the intended identity, color, and shape?
  • Does it remain attached to the correct position on the table?
  • Does it become hidden correctly when the hand passes in front?
  • Does the surrounding action still make sense?

Use the original task and evidence to define these questions before evaluating candidates. Otherwise, the evaluator may gradually accept whatever the editor happens to produce.

A VLM can assess the relationships, while tracking, segmentation, and frame inspection provide additional evidence. Human review remains useful for ambiguous cases and for measuring how well automatic acceptance agrees with the intended result.

Check the protected content

A simple preservation diagnostic measures the average RGB difference outside the approved mask:

E_outside =
    sum((1 - M_t(p)) * RGB_difference(Y_t(p), X_t(p)))
    / (3 * sum(1 - M_t(p)) + epsilon)

Here, RGB_difference is the sum of the absolute differences across the red, green, and blue channels. Both sums run over all frames and pixel positions.

The factor of three accounts for RGB channels, and epsilon is a small positive value that prevents division by zero.

For an exact composite in the working representation, this value should be zero. It is an implementation check that confirms protected pixels were retained.

It does not establish whether the generated cup is correct.

Learned perceptual distances can provide another view of visual change. Their research foundation concerns perceptual image similarity, so they should be used alongside separate checks for motion, identity, and task completion.

Also inspect small regions that matter to the task. A whole-frame average can dilute a visible change to a face, a hand, or a piece of text.

Check temporal continuity

Inspect the transition from the last original frame into the repaired interval, the motion within that interval, and the transition back to the original footage.

For the example, the boundary pairs are frames 71 and 72, followed by frames 83 and 84.

Look for changes in position, scale, lighting, shape, velocity, and contact with other objects. A cup can match the final reference frame while taking an implausible path to reach it.

Motion-compensated differences can help detect inconsistencies in regions with reliable correspondence. Exclude occlusions and intentional cuts from checks that assume continuous visible motion.

A low temporal difference is not automatically a good result. Freezing an object can reduce apparent flicker while violating the intended action. Verification must also check whether the correct movement occurred.

Finally, review the complete clip at normal playback speed. A repair that looks convincing frame by frame may still produce a noticeable pause or jump.

7. Accept a candidate only when the required checks pass

Candidate selection should reflect the requirements of the repair.

Suppose three hypothetical candidates restore the cup:

  • One changes its color.
  • One preserves its appearance but places it in front of the moving hand.
  • One preserves its identity, respects the hand’s occlusion, and connects cleanly to the surrounding frames.

A general visual-quality score might prefer either of the first two if they look sharper. The repair specification provides a reason to reject them.

For this task, acceptance should require that:

  1. The target defect is judged corrected.
  2. The intended prompt and identity constraints remain satisfied.
  3. Protected content meets the preservation requirement.
  4. Spatial and temporal boundaries pass inspection.
  5. The review process identifies no unacceptable new defect.

Avoid collapsing these conditions into a single average that lets a strong appearance score compensate for an unresolved error.

Thresholds should be chosen using representative examples and checked against human judgments. A model’s self-reported confidence is not automatically a calibrated probability that a repair is correct.

If no candidate passes, keep the source or the last accepted version.

8. Make retries controlled and reversible

A repair loop can become a source of accumulating damage if each failed attempt becomes the input to the next.

Keep the original clip immutable. Store each candidate with its mask, timestamps, prompt, model configuration, verification results, and processing cost.

When a candidate fails, use the failure to decide what should change:

  • A tracking error calls for a corrected mask.
  • A wrong object identity calls for better references or conditioning.
  • A temporal jump may require a different interval or more context.
  • A failed interaction may require editing a larger region.
  • An incorrect defect report should stop the repair altogether.

Repeatedly generating new candidates with the same faulty specification is unlikely to resolve the underlying issue.

Set a bounded attempt budget. Once that budget is exhausted, route the clip to a larger edit, full regeneration, or review.

For multiple accepted repairs, retain the union of the authorized edit regions and check whether the changes interact. Repairing a hand can invalidate an earlier assumption about an object it touches.

9. Compare local repair with full regeneration fairly

To find out whether the pipeline is useful, evaluate it on a collection of failed clips.

Include different defects, such as disappearing objects, malformed anatomy, inconsistent contact, and motion errors. Also include clean clips. An automatic repair system should be able to leave valid footage alone.

Compare at least three approaches:

Approach

What it reveals

Keep the original clip

Baseline defect rate and the value of abstaining

Apply targeted repair

Correction quality and preservation

Regenerate the complete clip

Whether starting again produces a better usable result

An independent frame-editing baseline can also help reveal the contribution of temporal processing.

Use the same original prompts, intended constraints, and evaluation policy. Keep related prompts and near-duplicate clips together when splitting development and test data.

Separate component performance from system performance

Evaluate the editor with manually checked intervals and masks. Then evaluate the complete pipeline using automatically produced intervals and masks.

The first test asks whether the editor can solve a correctly specified problem. The second asks whether the system can produce and execute that specification.

Without this separation, a strong editor can appear weak because it receives bad masks, or a fragile pipeline can look successful because every input was manually corrected.

Report outcomes that reflect actual use

Useful measurements include:

  • Target correction rate: How often the original defect is judged resolved.
  • Acceptance rate: How often the final output satisfies all required conditions.
  • New-defect rate: How often the attempt introduces another visible problem.
  • Preservation: Whether identity, composition, camera movement, and protected content remain acceptable.
  • Boundary failures: How often spatial seams or temporal jumps appear.
  • False intervention rate: How often valid footage is changed unnecessarily.
  • Cost per accepted output: Total processing and review cost divided by accepted results.

Include rejected candidates, exhausted retries, and fallbacks in the totals. Evaluating only successful repairs would hide the work required to obtain them.

Pixel preservation naturally favors a method that copies original pixels. Present it as a requirement of this editing task, alongside semantic quality and overall acceptance, rather than treating it as a universal measure of video quality.

10. A smaller edit does not automatically mean a cheaper pipeline

A mask may cover a tiny fraction of the clip while the editor still processes a substantial context window.

If the model encodes the entire window, reducing the masked area alone may do little to reduce computation. Detection, tracking, mask construction, verification, and retries also contribute to the total.

Compare measured processing time, compute, or cost. Equal numbers of generated candidates do not imply equal resource use.

A useful operational measure is:

Cost per accepted clip =
    Total detection, editing, verification, and review cost
    / Number of accepted clips

Report this alongside acceptance rate and quality. A cheap attempt that rarely produces an acceptable result may be less useful than a more expensive attempt with a higher success rate.

Keep the original frame timing and, where present, audio synchronization. A visual repair should not accidentally change the duration of the shot or shift its soundtrack.

When the repair should become a larger edit

Local repair is most attractive when the surrounding footage provides reliable constraints and the defect occupies a limited region or interval.

It becomes less suitable when the correction changes the meaning of the whole action.

If someone is supposed to pick up the cup but their hand never approaches it, adding the cup to a few frames will not complete the action. If the camera trajectory is inconsistent throughout the shot, a small patch cannot restore coherent geometry.

The repair region should expand only when the intended correction requires it. Once that region covers most of the scene or action, full regeneration may be the more sensible option.

The same applies when the desired content is ambiguous. An editor can generate a plausible correction, but the original video may not contain enough evidence to determine one uniquely correct result.

Conclusion

A useful video repair pipeline produces more than a new render. It produces a defined change, preserves the content outside that change, and retains evidence that the result passed the relevant checks.

VLMs can help explain what went wrong and assess whether the intended correction is visible. Tracking and segmentation define where the editor can work. Video inpainting generates candidate content. Compositing and verification determine whether that content belongs in the final clip.

For the disappearing cup, success means the same cup remains present, sits correctly on the table, interacts properly with the hand, and joins the surrounding footage without a visible interruption.

That is the standard worth building toward: a corrected moment inside a clip that was already worth keeping.

Cookie設定

Fix the Flaw, Keep the Clip: Building an AI Video Repair Pipeline | Artlint