Skip to content

Heavy distortion after cuts #15

Closed as not planned
Closed as not planned

Description

@awebeer256

I'm using model 4.1, on this video, downloaded in what youtube-dl/yt-dlp identifies as format number 248 (the default if you exclude resolutions above 1080p).

There is a "cut" between scenes/shots at 15 frames past the 11-second mark in the input video. In the output video (with default settings), this turns into a downright disorienting transition. Looking frame by frame, the first two frames after the cut are heavily distorted.

Here are those two frames, plus the next two for context:
adele_distortion_50fps

The culprit is the if block starting at line 227:

if ssim > 0.996:
    frame = read_buffer.get() # read a new frame
    if frame is None:
        break_flag = True
        frame = lastframe
    else:
        temp = frame
    I1 = torch.from_numpy(np.transpose(frame, (2,0,1))).to(device, non_blocking=True).unsqueeze(0).float() / 255.
    I1 = pad_image(I1)
    I1 = model.inference(I0, I1, args.scale)
    I1_small = F.interpolate(I1, (32, 32), mode='bilinear', align_corners=False)
    ssim = ssim_matlab(I0_small[:, :3], I1_small[:, :3])
    frame = (I1[0] * 255).byte().cpu().numpy().transpose(1, 2, 0)[:h, :w]

If I change the initial threshold from 0.996 to 1 (which I think disables the block because ssim can never be >1), the issue disappears:
adele_distortion_50fps_fixed

Activity

  1. hzwer commented on Oct 20, 2026

    @hzwer
    Owner

    Thank you for isolating the behavior to the ssim > 0.996 branch. That branch reads ahead and synthesizes a replacement frame, so it can cross a real cut before the later scene-change check. The current script still contains this logic; this is not being marked as a confirmed fix.

    For a local workaround, explicitly bypass the static-frame/read-ahead branch and process consecutive frames, or split the video at verified shot boundaries before interpolation. A proper fix would check the read-ahead pair for cuts before synthesis and preserve frame count/timing. That is safer than relying on a magic SSIM threshold of 1, and it should be tested on both repeated frames and cuts.

    Closing this thread, last updated before 2026, as part of the maintainer's backlog cleanup. This is administrative closure, not confirmation of a fix or completed feature. The discussion remains available. If further work is needed, please request reopening with current details, or open a new issue linking back here.

    Reply by gpt-6.1-astra (AI-assisted), posted at the repository maintainer's request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions