VideoHelp Forum




+ Reply to Thread
Results 1 to 11 of 11
  1. Hi, I'm looking to improve the picture quality of a DVD as much as possible. Would like to clean noise and remove dirt and upscale to 720p.

    Here is a short clip:https://easyupload.io/eh5xjt

    If anyone can take a look and guide me on this kindly.

    This is my script that I have:

    Code:
    a = LWlibavAudioSource("G:\Thundering Mantis files\demux\VTS_01_1 T81 2_0ch 192Kbps DELAY 0ms.ac3") # get audio (decompressed to PCM)
    v = Mpeg2Source("G:\Thundering Mantis files\demux\VTS_01_1.d2v", Info=3) # get video
    AudioDub(v,a) # join audio and video together
    AssumeFPS(24.0, sync_audio=true)
    ColorMatrix(mode="rec.601->rec.709")
    
    Crop(24,88,-10,-114)
    import("C:\Users\akuma\AviSynth+\plugins64+\RemoveDirtMC.avs")
    import("C:\Users\akuma\AviSynth+\plugins64+\santiag v1.6.avs")
    santiag() #removes the residual combing artefacts
    RemoveDirtMC(20, false)
    FineDehalo(rx=2.5, ry=2.0)
    DeHalo_Alpha(rx=2.0, ry=2.0, darkstr=1.0, brightstr=1.0, lowsens=50, highsens=50, ss=1.5)
    
    spline36resize(1200,720) #square pixels
    addborders(40,0,40,0) #pad to 1280x720
    SSRC(48000) # convert audio to 48000 Hz samples
    
    Prefetch(24)
    Quote Quote  
  2. In Vapoursynth I would probably start with something like:
    Code:
    # Imports
    import vapoursynth as vs
    # getting Vapoursynth core
    import ctypes
    import site
    import sys
    import os
    core = vs.core
    # Import scripts folder
    scriptPath = 'F:/Hybrid/64bit/vsscripts'
    sys.path.insert(0, os.path.abspath(scriptPath))
    os.environ["CUDA_MODULE_LOADING"] = "LAZY"
    # Loading Support Files
    Dllref = ctypes.windll.LoadLibrary("F:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
    # loading plugins
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libvs_placebo.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/FFT3DFilter/fft3dfilter.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools_sf_em64t.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/RemoveGrain/RemoveGrainVS.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vs-mlrt/vstrt.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libsangnom.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI2.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
    core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
    # Import scripts
    import edi_rpow2
    import G41Fun
    from importlib.machinery import SourceFileLoader
    vsmlrt = SourceFileLoader('vsmlrt', 'F:/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
    import havsfunc
    import mvsfunc
    import autowhite
    import validate
    # Source: 'C:\Users\Selur\Desktop\VTS_01_1.VOB'
    # Current color space: YUV420P8, bit depth: 8, resolution: 720x576, frame rate: 25fps, scanorder: progressive, yuv luminance scale: limited, matrix: 470bg, transfer: bt.470 system b/g, primaries: bt.601 pal, format: mpeg-2
    # Loading C:\Users\Selur\Desktop\VTS_01_1.VOB using DGSource
    clip = core.dgdecodenv.DGSource("J:/tmp/vob_941fdaaeda22090766694391cc4281d5_853323747.dgi")# 25 fps, scanorder: progressive
    frame = clip.get_frame(0)
    # setting color matrix to 470bg.
    clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
    # setting color transfer (vs.TRANSFER_BT470_BG), if it is not set.
    if validate.transferIsInvalid(clip):
      clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT470_BG)
    # setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
    if validate.primariesIsInvalid(clip):
      clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
    # setting color range to TV (limited) range.
    clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
    # making sure frame rate is set to 25fps
    clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
    # making sure the detected scan type is set (detected: progressive)
    clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE)# progressive
    # adjusting color space from YUV420P8 to RGB24 for vsAutoWhite
    clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
    # adjustint colors using AutoWhite
    clip = autowhite.AutoWhite(clip=clip)
    # adjusting color using Levels on RGB24 (8 bit)
    clip = core.std.Levels(clip=clip, min_in=16, max_in=235, min_out=16, max_out=235, gamma=0.95)
    # applying anti aliasing using santiag
    clip = havsfunc.santiag(c=clip, nns=2, qual=2, pscrn=2, opencl=True)
    from vsmlrt import Backend
    # adjusting color space from RGB24 to RGBH for vsDPIRmlrtDeblock
    clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, range_s="limited")
    # adjusting deblocking using DPIR (mlrt)
    clip = vsmlrt.DPIR(clip, strength=35.000, overlap=16, model=3, backend=Backend.TRT(fp16=True, device_id=0,verbose=True,use_cuda_graph=False, num_streams=3,builder_optimization_level=3,engine_folder="J:/TRT"))
    # adjusting color space from RGBH to YUV444P16 for vsDeHalo_Alpha
    clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited")
    # applying dehalo using DeHalo_alpha
    clip = havsfunc.DeHalo_alpha(clip, rx=2.50, ry=2.50)
    clip = core.std.Crop(clip=clip, left=26, right=10, top=88, bottom=114)# cropping to 684x374
    # removing grain using TemporalDegrain2
    clip = G41Fun.TemporalDegrain2(clip=clip, degrainPlane=4, meAlgPar=False, postFFT=0, fftThreads=1)
    clip = core.std.AddBorders(clip=clip, left=0, right=0, top=0, bottom=2)# add borders to archive mod 4 (NNEDI3(CL)) - 684x376
    # resizing using NNEDI3CL
    # current: 684x376 target: 1280x656 -> pow: 2
    clip = edi_rpow2.nnedi3cl_rpow2(clip=clip, rfactor=2, nsize=3, nns=4)# 1368x752
    clip = core.std.Crop(clip=clip, left=0, right=0, top=0, bottom=4)# removing borders (NNEDI3(CL)) - 1368x748
    # resizing 1368x748 to 1280x656
    clip = core.fmtc.resample(clip=clip, w=1280, h=656, kernel="spline64", interlaced=False, interlacedd=False)# before YUV444P16 after YUV444P16
    with open("F:/Hybrid/64bit/vsfilters/GLSL/parameterized/filmgrain.glsl") as glslf:
      glsl = glslf.read()
    glsl = glsl.replace('#define INTENSITY 0.05', '#define INTENSITY 0.05')
    clip = core.placebo.Shader(clip=clip, shader_s=glsl, width=clip.width, height=clip.height)
    # adjusting output color from: YUV444P16 to YUV420P10 for NVEncModel
    clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, range_s="limited", dither_type="error_diffusion")
    # set output frame rate to 25fps (progressive)
    clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
    # output
    clip.set_output()
    RemoveDirtMC seems overkill (so I would only apply it on selected scenes and/or additional masking)

    Cu Selur
    Image Attached Files
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  3. Thank you Selur, I don't have Vapoursynth on my computer, I only have Avisynth for now.
    Tried to install Vapoursynth but its not so simple for me. Will try following some youtube guide to get Vapoursynth installed and running and then I check out your script.

    Just seen your sample, looks much better. Thanks again.
    Quote Quote  
  4. Every filter (or at least similar filter) used in the script is also available in Avisynth, so no need to use Vapoursynth.
    AutoWhite => ColorYUV(autowhite=true) (http://avisynth.nl/index.php/ColorYUV)
    Levels => http://avisynth.nl/index.php/Levels
    DeHalo_alpha => http://avisynth.nl/index.php/DeHalo_alpha
    santiag => http://avisynth.nl/index.php/Santiag
    DPIR deblock => https://github.com/Asd-g/avs-mlrt/releases (alternatively, another non-gpu base deblocker can be used)
    nnedi3_rpow2 => http://avisynth.nl/index.php/Nnedi3/nnedi3_rpow2
    filmgrain => http://avisynth.nl/index.php/AddGrainC

    Cu Selur
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  5. Thanks again for this, much appreciated.
    Quote Quote  
  6. Originally Posted by Selur View Post
    Every filter (or at least similar filter) used in the script is also available in Avisynth, so no need to use Vapoursynth.
    AutoWhite => ColorYUV(autowhite=true) (http://avisynth.nl/index.php/ColorYUV)
    Levels => http://avisynth.nl/index.php/Levels
    DeHalo_alpha => http://avisynth.nl/index.php/DeHalo_alpha
    santiag => http://avisynth.nl/index.php/Santiag
    DPIR deblock => https://github.com/Asd-g/avs-mlrt/releases (alternatively, another non-gpu base deblocker can be used)
    nnedi3_rpow2 => http://avisynth.nl/index.php/Nnedi3/nnedi3_rpow2
    filmgrain => http://avisynth.nl/index.php/AddGrainC

    Cu Selur
    Hi Selur, I'm trying to match your Vapoursynth scrip on Avisynth but I'm not sure if im doing it correctly. My knowledge im all this is minimum.

    This is what i have written up:
    Code:
    a = LWlibavAudioSource("G:\Thundering Mantis files\demux\VTS_01_1 T81 2_0ch 192Kbps DELAY 0ms.ac3") # get audio (decompressed to PCM)
    v = Mpeg2Source("G:\Thundering Mantis files\demux\VTS_01_1.d2v", Info=3) # get video
    AudioDub(v,a) # join audio and video together
    AssumeFPS(24.0, sync_audio=true)
    ColorMatrix(mode="rec.601->rec.709")
    Crop(24,88,-10,-114)
    import("C:\Users\akuma\AviSynth+\plugins64+\santiag v1.6.avs")
    
    ColorYUV(autowhite=true)
    Levels(16, 0.95, 235, 0, 235, coring=true)
    santiag() #removes the residual combing artefacts
    mlrt_DPIR()
    FineDehalo(rx=2.5, ry=2.0)
    DeHalo_Alpha(rx=2.0, ry=2.0, darkstr=1.0, brightstr=1.0, lowsens=50, highsens=50, ss=1.5)
    TemporalDegrain2(degrainPlane=4, postFFT=0, fftThreads=1)
    nnedi3cl_rpow2(rfactor=2, nsize=3, nns=4)
    
    
    AddGrain(var=1, hcorr=1, vcorr=1, uvar=1, seed=1)
    I'm getting an errror:
    Image
    [Attachment 84276 - Click to enlarge]
    Quote Quote  
  7. The error message says it: DPIR expects the input to be 32bit
    adding
    Code:
    ConvertBits(32)
    ConvertToPlanarRGB()
    before the DPIR call should help.
    (+ you probably want to convert back to yuv420p8 afterward)

    Cu Selur
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  8. I will add this as you suggest.

    Also I can't figure out how to upscale on avisynth the same you've done on your vapoursynth script. I would like to get it to same size as your sample 1280 × 656 please.
    Quote Quote  
  9. Where is the problem?
    Simply add another resizer behind nnedi3cl_rpow2 to archive the desire resolution.
    users currently on my ignore list: deadrats, Stears555, marcorocchini
    Quote Quote  
  10. Originally Posted by Selur View Post
    The error message says it: DPIR expects the input to be 32bit
    adding
    Code:
    ConvertBits(32)
    ConvertToPlanarRGB()
    before the DPIR call should help.
    (+ you probably want to convert back to yuv420p8 afterward)

    Cu Selur
    Hi so when I use this, I get error message:

    Image
    [Attachment 84323 - Click to enlarge]


    I coudnt figure way round this, so I decided to use Deblock instead of mlrt_DPIR and added resizer nnedi3cl_rpow2now as you suggested. The script works now.

    Just for learning purpose, what could I have done to get DPIR working on my script?

    This is final script:

    Code:
    a = LWlibavAudioSource("G:\Thundering Mantis files\demux\VTS_01_1 T81 2_0ch 192Kbps DELAY 0ms.ac3") # get audio (decompressed to PCM)
    v = Mpeg2Source("G:\Thundering Mantis files\demux\VTS_01_1.d2v", Info=3) # get video
    AudioDub(v,a) # join audio and video together
    ColorMatrix(mode="rec.601->rec.709")
    Crop(26,88,-10,-114)
    import("C:\Users\akuma\AviSynth+\plugins64+\santiag v1.6.avs")
    ColorYUV(autowhite=true)
    Levels(16, 0.95, 235, 16, 235, coring=false)
    santiag(nns=2) #removes the residual combing artefacts
    Deblock(quant=35, aOffset=22, bOffset=22)
    dehalo_alpha(rx=2.5, ry=2.5, darkstr=1, lowsens=0, highsens=100, ss=1.0)
    TemporalDegrain2(degrainPlane=4, postFFT=0, fftThreads=1)
    NNEDI3CL_rpow2(rfactor=2, nsize=3, nns=4)
    Spline64Resize(1280,656)
    
    
    Prefetch(12)
    Thanks Selur, much apprecaited.
    Quote Quote  
  11. https://github.com/Asd-g/avs-mlrt/blob/85856d174d072ef97ae1986184b4776ea50b4849/script..._DPIR.avsi#L78
    Code:
    # model (default 0): What model to be used.
    # Folder "models" must be in the same location as mlrt_xxx.dll.
    /*
    0: "drunet_gray"
    1: "drunet_color"
    2: "drunet_deblocking_grayscale"
    3: "drunet_deblocking_color"
    */
    => since I used it for deblocking you should use model 3

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



Similar Threads

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