VideoHelp Forum
+ Reply to Thread
Results 1 to 9 of 9
Thread
  1. This code works fine until the prefetch is set to anything more than 1 thread. The more threads added to the prefetch, the more the random streaking.
    Are there any workarounds for this? Even 2 threads would be a good improvement.

    Code:
    SetFilterMTMode("DEFAULT_MT_MODE", 2)
    SetFilterMTMode("LWLibavVideoSource", 3)
    SetFilterMTMode("AviSource", 3)
    SetFilterMTMode("QTGMC", 2)
    SetFilterMTMode("DePanEstimate", 2)
    SetFilterMTMode("DePanStabilize", 2)
    SetFilterMTMode("Overlay", 2)
    SetFilterMTMode("Tweak", 2)
    SetFilterMTMode("Subtract", 2)
    SetFilterMTMode("Levels", 2)
    SetFilterMTMode("RgTools_RemoveGrain", 2)
    SetFilterMTMode("ConvertToYV12", 2)
    SetFilterMTMode("ConvertToYUY2", 2)
    # X = LWLibavVideoSource("C:\...\1.mkv", cache=false, prefer_hw=2).AssumeTFF().ConvertToYV12(interlaced=true).vsCnr2(ln=35,lm=192,un=47,um=255,vn=47,vm=255).ConvertToYUY2()#.DePulse()
    # source = LWLibavVideoSource("C:\...\1.mkv", cache=false, prefer_hw=2).AssumeTFF().ConvertToYUY2(interlaced=true)#.DePulse()
    #X = AviSource("C:\...\1.avi").AssumeTFF().ConvertToYUY2(interlaced=true)#.DePulse()
    source = AviSource("C:\...\1.avi").AssumeTFF().ConvertToYUY2(interlaced=true).SeparateFields()#.DePulse()
    
    # Preprocess source for reuse
    function Preprocess(clip src) {
        src.spatialsoften(1, 255, 127).ConvertToYV12().Greyscale().Tweak(0.0, 1.0, 0, 1.0, true, false)
    }
    
    function ProcessPass(clip src, clip preprocessed) {
        ghostA = preprocessed.VSLGhost(mode=3, shift=4, intensity=-128).Tweak(0.0, 1.01, 0, 1.25, true, false)
        ghostB = preprocessed.VSLGhost(mode=3, shift=1, intensity=-128).Tweak(0.0, 1.01, 0, 1.25, true, false)
        diffA = Subtract(ghostA, preprocessed).Levels(127, 1, 129, 0, 255).Invert().RgTools_RemoveGrain()
        diffB = Subtract(ghostB, preprocessed).Levels(127, 1, 129, 0, 255).Invert().RgTools_RemoveGrain()
        diff2 = Subtract(ghostA, ghostB).Invert()
    
        mask = diff2.Levels(50, 0.5, 255, 0, 255).Crop(2, 0, -0, -0).AddBorders(0, 0, 2, 0)
        halo_removed = Overlay(src, diff2, mask=mask, mode="subtract", opacity=0.5)
        halo_removed.Tweak(bright=12)
    }
    
    # Apply preprocessing and halo removal passes
    preprocessed = Preprocess(source)
    halo_rem1 = ProcessPass(source, preprocessed)
    preprocessed2 = Preprocess(halo_rem1)
    halo_rem2 = ProcessPass(halo_rem1, preprocessed2)
    preprocessed3 = Preprocess(halo_rem2)
    halo_rem3 = ProcessPass(halo_rem2, preprocessed3)
    preprocessed4 = Preprocess(halo_rem3)
    halo_rem4 = ProcessPass(halo_rem3, preprocessed4).ConvertToYV16()
    
    # Weave back + final processing
    afinal_output = halo_rem4.Dehalo_Alpha(rx=2, ry=2, lowsens=50, highsens=100).Blur(1, 0).ConvertToYUY2()#.Stab(dxmax=0,dymax=12)
    final_output = MergeChroma(afinal_output, source).Weave().ConvertToYV16(interlaced=true).Crop(4, 0, -8, -0).AddBorders(4, 0, 8, 0)#.Prefetch(2)#.BicubicResize(1920, 1440)
    return final_output
    Image Attached Thumbnails Click image for larger version

Name:	1.jpg
Views:	22
Size:	9.6 KB
ID:	81009  

    Click image for larger version

Name:	2.jpg
Views:	18
Size:	9.6 KB
ID:	81010  

    Quote Quote  
  2. Is 1.mkv an I-frame format ?

    Try cache=True for LWLibavVideoSource for that version. Cache=false can lead to non frame accurate seeks



    For the 1.avi version, is 1.avi an I-frame format ?

    You can also try adding Preroll(some value) before the prefetch if you're having linear access problems and mixed up frames
    http://avisynth.nl/index.php/Preroll
    Last edited by poisondeathray; 27th Jul 2024 at 12:26.
    Quote Quote  
  3. It's .avi encoded with HuffYUV
    Quote Quote  
  4. Preroll works to remove it, but only when the value is so high that everything slows down again, but thanks for the suggestion.
    Last edited by useraxe; 27th Jul 2024 at 13:08.
    Quote Quote  
  5. Does it make a difference between using LWLibavVideoSource and AviSource?
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  
  6. LWLibavVideoSource has it's own threads argument, although the docs says the default of threads=0 determines the number of threads automatically.

    I'd try downloading the MT Modes script via the "AviSynth+ MT modes" link here:
    http://avisynth.nl/index.php/AviSynth%2B#Help_filling_MT_modes

    Save it with an avsi extension and put it in the Avisynth+ plugins folder so it auto-loads, remove all the SetFilterMTMode lines from your script and try Prefetch again to see if that works any better. If you have avstp.dll auto-loading you should remove it, although the script I linked to above disables avstp's multi-threading anyway.

    Edit 1: I know they're commented out in your script, but Prefetch() should be the last line in the script unless there's a Return line, but I've never tried chaining it to a previous function the way you appear to be using it, so I've no idea if it'd be applied to the whole script that way. I'd normally do:

    Code:
    MergeChroma(afinal_output, source).Weave().ConvertToYV16(interlaced=true).Crop(4, 0, -8, -0).AddBorders(4, 0, 8, 0).BicubicResize(1920, 1440)
    
    Prefetch(2)
    or

    Code:
    final_output = MergeChroma(afinal_output, source).Weave().ConvertToYV16(interlaced=true).Crop(4, 0, -8, -0).AddBorders(4, 0, 8, 0).BicubicResize(1920, 1440)
    
    Prefetch(2)
    
    return final_output
    Edit 2: Some things I didn't know until I read this page:
    https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/syntax/syntax_internal_funct...ading_new.html
    Plugins that automatically register their MT mode with Avisynth+ won't use the MT mode you specify unless you add force=true to SetFilterMTMode()
    Since Avisyth+ 3.6 it's possible to use Prefetch() more than once in a script, but obviously it's something I haven't tried myself yet.
    Last edited by hello_hello; 28th Jul 2024 at 20:33.
    Quote Quote  
  7. Thanks Selur and hello_hello, but the issue is present.
    Quote Quote  
  8. I suspect the culprit is VsLGhost.

    I tried messing around with your script to see what I could see, and with only a single processing pass there was obvious artifacts in places.

    Code:
    function Preprocess(clip src) {
        src.ConvertToYUY2().spatialsoften(1, 255, 127).ConvertToYV24().Greyscale().Tweak(0.0, 1.0, 0, 1.0, true, false)
    }
    
    function ProcessPass(clip src, clip preprocessed) {
        ghostA = preprocessed.VSLGhost(mode=3, shift=4, intensity=-128).Tweak(0.0, 1.01, 0, 1.25, true, false)
        ghostB = preprocessed.VSLGhost(mode=3, shift=1, intensity=-128).Tweak(0.0, 1.01, 0, 1.25, true, false)
        diffA = Subtract(ghostA, preprocessed).Levels(127, 1, 129, 0, 255).Invert().RgTools_RemoveGrain()
        diffB = Subtract(ghostB, preprocessed).Levels(127, 1, 129, 0, 255).Invert().RgTools_RemoveGrain()
        diff2 = Subtract(ghostA, ghostB).Invert()
    
        mask = diff2.Levels(50, 0.5, 255, 0, 255).Crop(2, 0, -0, -0).AddBorders(0, 0, 2, 0)
        halo_removed = Overlay(src, diff2, mask=mask, mode="subtract", opacity=0.5)
        halo_removed.Tweak(bright=12)
    }
    
    preprocessed = Preprocess(source)
    halo_rem1 = ProcessPass(source, preprocessed)
    
    afinal_output = halo_rem1.Dehalo_Alpha(rx=2, ry=2, lowsens=50, highsens=100)
    MergeChroma(afinal_output, source).ConvertToYV16()
    VsLGhost must register itself as an MT_NICE_FILTER. At least I assume it does, but does anyone know if there's a way to determine the MT mode a plugin is using? Anyway, disabling multi-threading stopped the artifacts from appearing, as did specifying MT mode 2 for VsLGhost with multi-threading enabled, but you need to be forceful about it otherwise it doesn't have any affect.

    SetFilterMTMode("VsLGhost", 2, force=true)

    Here's the sort of thing I was seeing in places.

    No multi-threading.



    The artifacts are mostly along the edge of the door.

    Quote Quote  
  9. VsLGhost must register itself as an MT_NICE_FILTER. At least I assume it does, but does anyone know if there's a way to determine the MT mode a plugin is using?
    Look at the source if it's open source.
    Code:
        int __stdcall SetCacheHints(int cachehints, int frame_range)
        {
            return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
        }
    see: https://github.com/Asd-g/AviSynthPlus-vsLGhost/blob/master/src/vsLGhost.h

    Cu Selur
    users currently on my ignore list: deadrats, Stears555
    Quote Quote  



Similar Threads

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