VideoHelp Forum
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. Hello, I have a 10 minute full show in HD quality, which is in great state. But then, not sure how did production company let this slip in, but there is 2 sec scene where they incorrectly deinterlaced video without properly debanding the fields.
    It is a stretch, but since rest of the video is in great quality, would there be a way to fix this 2 second scene, please? At least partially? I was thinking maybe to first downsize and then deband/deflicker might help?
    Thank you.
    Image Attached Files
    Quote Quote  
  2. Sorry, this is not a solution to the problem!
    Just something I thought I try since I was wondering what it would do if I applied a motion masked BasicVSR++ two times in a row on such content. (script: https://pastebin.com/qZYX0W3Y)
    On some frames, this does really seem to help, but for some it makes is worse and doesn't do much for others.
    Just thought I share the result, so others know that it does not really work.

    Cu Selur
    Ps.: in my book this has nothing to do with banding, but not deinterlacing and then cropping and resizing while not taking into account that the source was interlaced,...
    Image Attached Files
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  3. Go to post #36 and #37 in this thread at doom9.org where I provide the code I created to fix video which had been resized without first being deinterlaced:

    Repair Bad Deinterlacing

    Note that this fix was specific to the height of the bands created by that video's resizing. I never got around to generalizing the function for any height band. If you read a few of my posts in that thread, you'll see how I suggested that the function could be changed for other situations.
    Last edited by johnmeyer; 15th Aug 2024 at 20:29. Reason: Fixed links; later on, I fixed a typo
    Quote Quote  
  4. Originally Posted by johnmeyer View Post
    Go to post #36 and #37 in this thread at doom9.org where I provide the code I created to fix video which had been resized without first being deinterlaced:

    Repair Bad Deinterlacing

    Note that this fix was specific to the height of the bands created by that video's resizing. I never got around to generalizing the function for any height band. If you read a few of my posts in that thread, you'll see how I suggested that the function could be changed for other situations.
    Oh wow, this is phenomenal script! I tested it and it works wonders. Although I found an issue with my video. Not sure about the referenced Kiss video, but my video was 25 fps interlaced, then the production company badly deinterlaced to 50 fps, but then dropped the each second frame converting it back to 25 fps. Thus, now I realized I am missing half the information.

    So I think my issue is that if I had original badly interlaced video with 50 fps, the script would perfectly align the fields. See the test below (Deband2.mp4). However, as I am missing half the frames, I have first row of 12 fields from frame A and second row of 12 fields from frame B. When I put the fields into two separate videos (Deband3.mp4), you can see that the bad deinterlation is gone, but you can see the missing fields which were lost when they converted 50 fps to 25 fps. I tried RIFE interpolation to add missing frames too, but of course they do not following 12 row banding so that didn't give the proper result. But I am shocked about the script. It works perfectly and does wonders. :O

    Code:
    SetFilterMTMode ("QTGMC", 2)
    #FFmpegSource2("Balenciaga FW06 only.mpg", atrack=-1)
    audiofile1 = BestAudioSource("deband.mp4", track=-1)
    videofile1 = FFVideoSource("deband.mp4", track=-1,threads=1).Spline64Resize(938,528).converttoyuy2()
    
    
    global scenethreshold=4
    source = audiodub(videofile1,audiofile1)
    global prev_source = selectevery(source, 1, -1)
    #Spline64Resize(source,938,528)
    
    
    # Adjust cropping based on new resolution and stripe height
    clip1  = crop(source, 0, 0, 938, 12)
    clip2  = crop(source, 0, 12, 938, 12)
    clip3  = crop(source, 0, 24, 938, 12)
    clip4  = crop(source, 0, 36, 938, 12)
    clip5  = crop(source, 0, 48, 938, 12)
    clip6  = crop(source, 0, 60, 938, 12)
    clip7  = crop(source, 0, 72, 938, 12)
    clip8  = crop(source, 0, 84, 938, 12)
    clip9  = crop(source, 0, 96, 938, 12)
    clip10 = crop(source, 0, 108, 938, 12)
    clip11 = crop(source, 0, 120, 938, 12)
    clip12 = crop(source, 0, 132, 938, 12)
    clip13 = crop(source, 0, 144, 938, 12)
    clip14 = crop(source, 0, 156, 938, 12)
    clip15 = crop(source, 0, 168, 938, 12)
    clip16 = crop(source, 0, 180, 938, 12)
    clip17 = crop(source, 0, 192, 938, 12)
    clip18 = crop(source, 0, 204, 938, 12)
    clip19 = crop(source, 0, 216, 938, 12)
    clip20 = crop(source, 0, 228, 938, 12)
    clip21 = crop(source, 0, 240, 938, 12)
    clip22 = crop(source, 0, 252, 938, 12)
    clip23 = crop(source, 0, 264, 938, 12)
    clip24 = crop(source, 0, 276, 938, 12)
    clip25 = crop(source, 0, 288, 938, 12)
    clip26 = crop(source, 0, 300, 938, 12)
    clip27 = crop(source, 0, 312, 938, 12)
    clip28 = crop(source, 0, 324, 938, 12)
    clip29 = crop(source, 0, 336, 938, 12)
    clip30 = crop(source, 0, 348, 938, 12)
    clip31 = crop(source, 0, 360, 938, 12)
    clip32 = crop(source, 0, 372, 938, 12)
    clip33 = crop(source, 0, 384, 938, 12)
    clip34 = crop(source, 0, 396, 938, 12)
    clip35 = crop(source, 0, 408, 938, 12)
    clip36 = crop(source, 0, 420, 938, 12)
    clip37 = crop(source, 0, 432, 938, 12)
    clip38 = crop(source, 0, 444, 938, 12)
    clip39 = crop(source, 0, 456, 938, 12)
    clip40 = crop(source, 0, 468, 938, 12)
    clip41 = crop(source, 0, 480, 938, 12)
    clip42 = crop(source, 0, 492, 938, 12)
    clip43 = crop(source, 0, 504, 938, 12)
    clip44 = crop(source, 0, 516, 938, 12)
    
    fram1 = BlankClip(length=FrameCount(source), width=938, height=264, fps=25, color=$000000).converttoyuy2()
    fram1 = overlay(fram1, clip1, 0, 0)
    fram1 = overlay(fram1, clip3, 0, 12)
    fram1 = overlay(fram1, clip5, 0, 24)
    fram1 = overlay(fram1, clip7, 0, 36)
    fram1 = overlay(fram1, clip9, 0, 48)
    fram1 = overlay(fram1, clip11, 0, 60)
    fram1 = overlay(fram1, clip13, 0, 72)
    fram1 = overlay(fram1, clip15, 0, 84)
    fram1 = overlay(fram1, clip17, 0, 96)
    fram1 = overlay(fram1, clip19, 0, 108)
    fram1 = overlay(fram1, clip21, 0, 120)
    fram1 = overlay(fram1, clip23, 0, 132)
    fram1 = overlay(fram1, clip25, 0, 144)
    fram1 = overlay(fram1, clip27, 0, 156)
    fram1 = overlay(fram1, clip29, 0, 168)
    fram1 = overlay(fram1, clip31, 0, 180)
    fram1 = overlay(fram1, clip33, 0, 192)
    fram1 = overlay(fram1, clip35, 0, 204)
    fram1 = overlay(fram1, clip37, 0, 216)
    fram1 = overlay(fram1, clip39, 0, 228)
    fram1 = overlay(fram1, clip41, 0, 240)
    fram1 = overlay(fram1, clip43, 0, 252)
    
    fram2 = BlankClip(length=FrameCount(source), width=938, height=264, fps=25, color=$000000).converttoyuy2()
    fram2 = overlay(fram2, clip2, 0, 0)
    fram2 = overlay(fram2, clip4, 0, 12)
    fram2 = overlay(fram2, clip6, 0, 24)
    fram2 = overlay(fram2, clip8, 0, 36)
    fram2 = overlay(fram2, clip10, 0, 48)
    fram2 = overlay(fram2, clip12, 0, 60)
    fram2 = overlay(fram2, clip14, 0, 72)
    fram2 = overlay(fram2, clip16, 0, 84)
    fram2 = overlay(fram2, clip18, 0, 96)
    fram2 = overlay(fram2, clip20, 0, 108)
    fram2 = overlay(fram2, clip22, 0, 120)
    fram2 = overlay(fram2, clip24, 0, 132)
    fram2 = overlay(fram2, clip26, 0, 144)
    fram2 = overlay(fram2, clip28, 0, 156)
    fram2 = overlay(fram2, clip30, 0, 168)
    fram2 = overlay(fram2, clip32, 0, 180)
    fram2 = overlay(fram2, clip34, 0, 192)
    fram2 = overlay(fram2, clip36, 0, 204)
    fram2 = overlay(fram2, clip38, 0, 216)
    fram2 = overlay(fram2, clip40, 0, 228)
    fram2 = overlay(fram2, clip42, 0, 240)
    fram2 = overlay(fram2, clip44, 0, 252)
    
    prev_fram2 = selectevery(fram2, 1, -1)
    super = MSuper(prev_fram2, pel = 2)
    vfe = manalyse(super, truemotion = true, isb = false, delta = 1, blksize = 8, overlap = 4, search = 6)
    vbe = manalyse(super, truemotion = true, isb = true, delta = 1, blksize = 8, overlap = 4, search = 6)
    fram2_est = mflowinter(prev_fram2, super, vbe, vfe, time = 50, blend = false, mL = 100)
    
    new_clip = BlankClip(length = FrameCount(source), width = 938, height = 528, fps = 25, color=$000000).converttoyuy2()
    new_clip = overlay(new_clip, crop(fram1, 0, 0, 938, 12), 0, 0)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 0, 938, 12), 0, 12)
    new_clip = overlay(new_clip, crop(fram1, 0, 12, 938, 12), 0, 24)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 12, 938, 12), 0, 36)
    new_clip = overlay(new_clip, crop(fram1, 0, 24, 938, 12), 0, 48)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 24, 938, 12), 0, 60)
    new_clip = overlay(new_clip, crop(fram1, 0, 36, 938, 12), 0, 72)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 36, 938, 12), 0, 84)
    new_clip = overlay(new_clip, crop(fram1, 0, 48, 938, 12), 0, 96)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 48, 938, 12), 0, 108)
    new_clip = overlay(new_clip, crop(fram1, 0, 60, 938, 12), 0, 120)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 60, 938, 12), 0, 132)
    new_clip = overlay(new_clip, crop(fram1, 0, 72, 938, 12), 0, 144)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 72, 938, 12), 0, 156)
    new_clip = overlay(new_clip, crop(fram1, 0, 84, 938, 12), 0, 168)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 84, 938, 12), 0, 180)
    new_clip = overlay(new_clip, crop(fram1, 0, 96, 938, 12), 0, 192)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 96, 938, 12), 0, 204)
    new_clip = overlay(new_clip, crop(fram1, 0, 108, 938, 12), 0, 216)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 108, 938, 12), 0, 228)
    new_clip = overlay(new_clip, crop(fram1, 0, 120, 938, 12), 0, 240)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 120, 938, 12), 0, 252)
    new_clip = overlay(new_clip, crop(fram1, 0, 132, 938, 12), 0, 264)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 132, 938, 12), 0, 276)
    new_clip = overlay(new_clip, crop(fram1, 0, 144, 938, 12), 0, 288)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 144, 938, 12), 0, 300)
    new_clip = overlay(new_clip, crop(fram1, 0, 156, 938, 12), 0, 312)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 156, 938, 12), 0, 324)
    new_clip = overlay(new_clip, crop(fram1, 0, 168, 938, 12), 0, 336)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 168, 938, 12), 0, 348)
    new_clip = overlay(new_clip, crop(fram1, 0, 180, 938, 12), 0, 360)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 180, 938, 12), 0, 372)
    new_clip = overlay(new_clip, crop(fram1, 0, 192, 938, 12), 0, 384)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 192, 938, 12), 0, 396)
    new_clip = overlay(new_clip, crop(fram1, 0, 204, 938, 12), 0, 408)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 204, 938, 12), 0, 420)
    new_clip = overlay(new_clip, crop(fram1, 0, 216, 938, 12), 0, 432)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 216, 938, 12), 0, 444)
    new_clip = overlay(new_clip, crop(fram1, 0, 228, 938, 12), 0, 456)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 228, 938, 12), 0, 468)
    new_clip = overlay(new_clip, crop(fram1, 0, 240, 938, 12), 0, 480)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 240, 938, 12), 0, 492)
    new_clip = overlay(new_clip, crop(fram1, 0, 252, 938, 12), 0, 504)
    new_clip = overlay(new_clip, crop(fram2_est, 0, 252, 938, 12), 0, 516)
    
    GSCript("""
        Function Select_Op(clip clp, int current_frame) {    # Detect first frame after scene change
            clp
            nd = RT_YDifference(Last, n=current_frame - 1, delta= 1)  # We detect relative to previous frame, ie for 1st frame after SC
            pd = Max(RT_YDifference(Last, n=current_frame - 1, delta=-1), 0.00001)
            Sop = (nd / pd > scenethreshold) ? 0 : 1
            Sop # 0=scene change 1st frame : 1=not scene change
        }
    """)
    
    BLUE = $29F06E                  # YUV BLUE
    
    msk = new_clip.BlankClip(length=1, color=000000)
    stripe = new_clip.BlankClip(height=2, color_yuv=BLUE)
    GSCript("""
        for(y=8, msk.height-2, 18) {
            msk = msk.overlay(stripe, 0, y)
        }
    """)
    
    EXL_AMOUNT = 256 # Strength of S_Exlogo mixing, greater more opaque delogo (256 max)
    
    Import("C:\Users\AviSynth+\plugins64+\s_ExLogo.AVS")
    Exl = new_clip
    GSCript("""
        for(y=8, exl.height-2, 18) {
            exl = exl.S_Exlogo(0, y, -0, 2, BlurMode=5, amount=EXL_AMOUNT)
        }
    """)
    
    Fixed = Exl
    
    # Use original clip at scene changes: Detect on Source clip rather than prev_source
    ConditionalSelect(source, "Last.Select_Op(current_frame)", source, Fixed, show=false)
    
    stackhorizontal(source, Last)
    return Last
    Image Attached Files
    Last edited by JadHC; 16th Aug 2024 at 06:41. Reason: editing paths to files
    Quote Quote  
  5. also did a quick test of compresing heights and converting the band of twelve rows into one and run it through QTGMC. It properly gave me what original debanded video looked like (deband1.mp4), but of course as I compressed 12 rows into 1, i lost too much video information and the video is very blurry now.

    I realized that the scene actually has only 61 frames, so maybe over the weekend, i could fix individual frames in photoshop using the magic tool. I try to avoid doing that but having only 61 frames, this could take about an hour or even less.
    Image Attached Files
    Quote Quote  
  6. Originally Posted by Selur View Post
    Sorry, this is not a solution to the problem!
    Just something I thought I try since I was wondering what it would do if I applied a motion masked BasicVSR++ two times in a row on such content. (script: https://pastebin.com/qZYX0W3Y)
    On some frames, this does really seem to help, but for some it makes is worse and doesn't do much for others.
    Just thought I share the result, so others know that it does not really work.

    Cu Selur
    Ps.: in my book this has nothing to do with banding, but not deinterlacing and then cropping and resizing while not taking into account that the source was interlaced,...
    thank you, Selur. This is also very interesting. Always excited to read your insightful posts and advices.
    Quote Quote  
  7. Having half the frames missing obviously is going to degrade the result because the motion estimation has half the temporal information it would expect and will have more errors. I don't have a solution to that, off the top of my head.
    Quote Quote  
  8. Originally Posted by johnmeyer View Post
    Having half the frames missing obviously is going to degrade the result because the motion estimation has half the temporal information it would expect and will have more errors. I don't have a solution to that, off the top of my head.
    you actually helped me tremendously and guided me the right way. Over the weekend, I added white areas over the debanded frames:

    Image
    [Attachment 81588 - Click to enlarge]


    then I did batch script and used content aware fill in Photoshop which fixed the rigged edges in most scenes.

    Image
    [Attachment 81589 - Click to enlarge]


    Then I overlapped the content aware fill over original image and kept areas that worked well from each frame. If neighboring frame had better details, i copied them over and blended them in (stretched, liquified, rotated). For remaining stuff, i used paint brush to fix stuff where needed

    Image
    [Attachment 81590 - Click to enlarge]


    i did it all for 61 frames and I think i got most of the debanding gone (attached video). After interpolating, It looks very well. I can clean up some details in couple frames that could be better. But overall, I am very happy that this was fixable and bad interpolation is gone! Thank you for your help! I would have never gotten here without you! Plus, I learnt a new script!
    Image Attached Files
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!