Go Back    Forum > Digital Video > Video Project Help > Restore, Filter, Improve Quality

LinkBack Thread Tools
10-28-2022, 02:41 PM
Selur Selur is offline
Free Member
Join Date: Feb 2022
Posts: 38
Thanked 12 Times in 10 Posts
Here's quick go from me at it:

# Imports
import vapoursynth as vs
import os
import ctypes
# Loading Support Files
Dllref = ctypes.windll.LoadLibrary("i:/Hybrid/64bit/vsfilters/Support/libfftw3f-3.dll")
import sys
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'i:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
# Import scripts
import SpotLess
import chromashift
import adjust
import havsfunc
# source: 'C:\Users\Selur\Desktop\sample.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 720x576, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: bottom field first
# Loading C:\Users\Selur\Desktop\sample.avi using LWLibavSource
clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/sample.avi", format="YUV420P8", stream_index=0, cache=0, prefer_hw=0)
# Setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=5)
clip = clip if not core.text.FrameProps(clip,'_Transfer') else core.std.SetFrameProps(clip, _Transfer=5)
clip = clip if not core.text.FrameProps(clip,'_Primaries') else core.std.SetFrameProps(clip, _Primaries=5)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=1)
# setting field order to what QTGMC should assume (bottom field first)
clip = core.std.SetFrameProp(clip=clip, prop="_FieldBased", intval=1)
# Deinterlacing using QTGMC
clip = havsfunc.QTGMC(Input=clip, Preset="Fast", TFF=False, opencl=True) # new fps: 50
# make sure content is preceived as frame based
clip = core.std.SetFieldBased(clip, 0)
# sharpening using AWarpSharp2
clip = core.warp.AWarpSharp2(clip=clip, blur=2, depth=64, chroma=True, planes=[1,2])
# Color Adjustment
clip = adjust.Tweak(clip=clip, hue=0.00, sat=0.75, cont=1.00, coring=True)
# Chroma adjustment using ChromaShiftSP
clip = chromashift.ChromaShiftSP(clip=clip, X=2.40)
# adjusting color space from YUV420P8 to RGBS for vsGrayworld
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
# Color Adjustment using Grayworld
# convert to linear color space
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", range_s="limited")
# limit to 0-1
clip = core.std.Limiter(clip, 0.0, 1.0)
clip = core.grwrld.grayworld(clip=clip, cc=0)
# undo conversion to linear color space
clip = core.resize.Bicubic(clip=clip, format=vs.RGBS, matrix_in_s="470bg", transfer_in_s="linear", range_s="limited")
# adjusting color space from RGBS to YUV444P16 for vsSpotLess
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_s="limited", dither_type="error_diffusion")
clip = SpotLess.SpotLess(clip=clip, radT=3, thsad=16000)
# cropping the video to 688x568
clip = core.std.CropRel(clip=clip, left=16, right=16, top=4, bottom=4)
# denoising using KNLMeansCL
clip = havsfunc.KNLMeansCL(clip=clip, d=3)
# contrast sharpening using CAS
clip = core.cas.CAS(clip=clip, sharpness=0.600)
# applying dehalo using YAHR
clip = havsfunc.YAHR(clip, blur=4, depth=96)
clip = havsfunc.DeHalo_alpha(clip)
# Resizing using 10 - bicubic spline
clip = core.fmtc.resample(clip=clip, kernel="spline16", w=704, h=546, interlaced=False, interlacedd=False) # resolution 704x546
# adjusting output color from: YUV444P16 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, dither_type="error_diffusion", format=vs.YUV420P10, range_s="limited")
# set output frame rate to 50fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=50, fpsden=1)
# Output
What I used:
  • QTGMC for deinterlacing
  • aWarpSharp to sharpen chroma
  • Tweak to lower saturation
  • ChromaShift to shift chroma a bit
  • Grayworld to adjust general coloring
  • SpotLess to get rid of some of the noise (could be tweaked more)
  • KNLMeansCL for some denoising (could be tweaked more)
  • CAS for some contrast sharpening
  • YAHR an DeHaloAlpha to lessen the halos (this worked better than expected)
could use some tweaking and maybe adjusting of the filter order.

Cu Selur

Attached Files
File Type: mp4 sample.mp4 (2.58 MB, 12 downloads)
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
11-16-2022, 07:43 AM
lollo2 lollo2 is offline
Free Member
Join Date: Mar 2013
Location: Italy
Posts: 673
Thanked 185 Times in 161 Posts
Reel.Dell on doom9 forum developed/modified the "Dering" plugin just for this purpose. Good results were achieved:


A channel on S-VHS / VHS capture and AviSynth restoration https://bit.ly/3mHWbkN
Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
VHS Capture, Halo effect correction? Closecall Restore, Filter, Improve Quality 2 05-19-2022 03:20 AM
Ridding myself of VCR ghosts? Hushpower Restore, Filter, Improve Quality 11 05-20-2020 06:59 PM
Am I chasing RFI video ghosts / being too critical? rocko Capture, Record, Transfer 12 03-18-2015 12:40 AM
TBC-1000 effects on composite signal jonasz Restore, Filter, Improve Quality 6 07-23-2014 07:10 AM
Possible to fix analogue TV echo/halo problem? Pate Restore, Filter, Improve Quality 5 10-04-2012 02:15 PM

Thread Tools

All times are GMT -5. The time now is 03:24 AM