VideoHelp Forum
+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 31 to 34 of 34
Thread
  1. Originally Posted by johnmeyer View Post
    Here is a link to not only the script, but the discussion which surrounded my development of the script so you can get some idea of how it works:

    Finding individual "bad" frames in video; save frame number; or repair

    If you want to use the script, I posted a better version later in that thread:

    Better Version of Script
    This post came just right in time. The script identified/fixed about 80.... 90% of the overexposed flashlight frames of a tape capture of a wedding party. Saved a lot of manual work and time. Thanks!
    Quote Quote  
  2. Originally Posted by Sharc View Post
    Originally Posted by johnmeyer View Post
    Here is a link to not only the script, but the discussion which surrounded my development of the script so you can get some idea of how it works:

    Finding individual "bad" frames in video; save frame number; or repair

    If you want to use the script, I posted a better version later in that thread:

    Better Version of Script
    This post came just right in time. The script identified/fixed about 80.... 90% of the overexposed flashlight frames of a tape capture of a wedding party. Saved a lot of manual work and time. Thanks!
    Thanks for posting. I'm glad it worked for you!

    As I think I mentioned somewhere in the thread where I posted that script, photographer's flashes sometimes include several "pre-flashes." If there is at least one non-flash frame on either side, the script will repair those as well, but if they are fast enough that they happen over consecutive frames, the script will fail. Put another way, the bad frame must have a good frame on either side for the script to detect that it doesn't belong and therefore needs to be removed.

    I am pretty happy with that script. You can sometimes improve its effectiveness if you take a few minutes to look at the metrics and then change the detection threshold. For most videos, you can actually err on the side of having it find too many "bad" frames. While this results in some good frames being replaced, the motion estimation is usually so good that you don't notice.

    Now if I could just finally figure out how to "perfect" the script I wrote which fixes bad streaming and bad captures where you end up with dropped frames followed by dups. It actually works as well as this one, but my method requires breaking down the video into groups of frames. If the dup/drop pair happens on either side of the boundary between groups, it gets missed. It removes 80-90% of the problem, but if I can ever figure out a way around the problem, it should get 99+%.

    Need help "perfecting" script to delete drops and dups
    Quote Quote  
  3. Member
    Join Date
    Aug 2023
    Location
    Goiânia
    Search Comp PM
    Originally Posted by jagabo View Post
    Here's the script as I have it now:

    Code:
    ##########################################################################
    #
    # Abs(Y1-Y2)
    #
    # Works for YUY2 and YV12 only
    #
    ##########################################################################
    
    function AbsSubtractY(clip v1, clip v2)
    {
        IsYUY2(v1) ? mt_lutxy(v1.ConvertToYV16(), v2.ConvertToYV16(),"x y - abs", chroma="-128").ConvertToYUY2() \
                  : mt_lutxy(v1, v2,"x y - abs", chroma="-128")
    }
    
    ##########################################################################
    #
    # Saturation mask, rough approximation
    #
    ##########################################################################
    
    function SaturationMask(clip c)
    {
        U = UtoY(c)
        V = VtoY(c)
        mt_lutxy(U, V, expr="x 128 - abs 2 * dup *    y 128 - abs 2 * dup *   + 0.5 ^")
        PointResize(c.width, c.height)
    }
    
    ##########################################################################
    #
    # Copy lighter pixels from previous and next frames in very high saturation areas.
    #
    ##########################################################################
    
    function LightenBlackDots(clip c)
    {
        lightened = Overlay(c, c.Loop(2,0,0), mode="lighten") # overlaylighter pixels from previous frame
        lightened = Overlay(lightened, c.Trim(1,0), mode="lighten") # overly lighter pixels from next frame
        SatMask = SaturationMask(c).ColorYUV(gain_y=400, off_y=-200).mt_expand() # an alpha mask based on saturation
        Overlay(c, lightened, mask=SatMask) # limit black dot removal to high saturation areas
    }
    
    ##########################################################################
    #
    # Shift the frame down by N lines if it's detected as shifted up by N lines relative to the next.
    # Works well for static shots, probably not for high motion shots.
    #
    ##########################################################################
    
    function DownShift(clip c, int lines)
    {
        c
        AbsDiffShifted = AbsSubtractY(Crop(0,0,-0,-lines).AddBorders(0,lines,0,0), Trim(1,0))
        AbsDiffLast = AbsSubtractY(last, Trim(1,0))
        TestFrame = Subtract(AbsDiffLast, AbsDiffShifted).Crop(32,32,-32,-32).AddBorders(32,32,32,32,color=$7f7f7f)
    
        ConditionalFilter(TestFrame, Overlay(last.Trim(1,0), last, x=0, y=lines), last, "AverageLuma", "greaterthan", "129")
    }
    
    ##########################################################################
    #
    # Main script
    #
    ##########################################################################
    
    LWLibavVideoSource("copia.mkv", cache=false, prefer_hw=2) 
    
    #
    # reduce MPEG DCT blocking, interlaced
    #
    
    SeparateFields()
    Deblock(quant=40)
    Weave()
    
    #
    # deinterlace
    #
    
    QTGMC(Sharpness=0.0)
    
    #
    # reduce over sharpening halos
    #
    
    dehalo_alpha(rx=3, ry=3) # alternatively, FineDehalo() will fix only the strongest halos and remove less detail
    
    #
    # lighten black dots in high saturation areas.  You may want to limit this to the early part of the video
    #
    
    LightenBlackDots()
    
    #
    #  General noise reduction, cleaning
    #
    
    SMDegrain(thsad=300, tr=3)  # temporal noise reduction
    MergeChroma(aWarpSharp2(depth=20)) # sharpen chroma
    ChromaShiftSP(x=2, y=2) # shift the chroma to better align with luma
    
    #
    # Shift down frames that are detected as shifted up by 20 lines
    # Up to 4 in a row with four calls
    #
    
    DownShift(20) # fix single frames shifted up by 20 lines
    DownShift(20) # again to cover two in a row
    DownShift(20) # again to cover three in a row
    DownShift(20) # again to cover four  in a row
    
    #
    # Further stabilize frame bounce
    # Stab doesn't work for very large bounce (like 20 lines)
    #
    
    Crop(16,8,-16, -48)
    Stab(dxmax=4, dymax=8, range=2, mirror=15)
    # AddBorders(16,8,16,48) # restore frame size if needed
    
    prefetch(20)
    Hello big friend,
    I've been studying Avisyth, and I'm finally able to process the command lines of your Script.
    However, when I try to run the Stab filter, the following error appears in the attached photo, could you help me please?
    Image Attached Thumbnails Click image for larger version

Name:	Stab error.png
Views:	11
Size:	60.5 KB
ID:	73944  

    Quote Quote  



Similar Threads

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