This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Restoring badly digitized VHS
#11
To me, 4-weave doesn't really seem stable, but I agree the text is not broken.
That said, I too would have expected for your code to work, but I suspect somewhere ffmpeg does some interpolation, so upscaling before Stab and downscaling afterwards:
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import ctypes
import sys
import os
core = vs.core
# Limit frame cache to 48473MB
core.max_cache_size = 48473
# Import scripts folder
scriptPath = 'F:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# 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/libmotionmask.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ColorFilter/Retinex/Retinex.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/vszip.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/CTMF/CTMF.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/TCanny.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libfillborders.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libtemporalmedian.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/Cnr2/libcnr2.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SharpenFilter/MSmooth/libmsmoosh.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/FrameFilter/ReduceFlicker/ReduceFlicker.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/GrainFilter/AddGrain/AddGrain.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/NEO_FFT3DFilter/neo-fft3d.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/DFTTest/DFTTest.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/EEDI3m_opencl.dll")# vsQTGMC
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/ResizeFilter/nnedi3/NNEDI3CL.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DeinterlaceFilter/Bwdif/Bwdif.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/akarin.dll")
core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV_AVX2.dll")
# defining beforeDeCross-function - START
def beforeDeCross(clip):
  core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/MiscFilter/MiscFilters/MiscFilters.dll")
  core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/DenoiseFilter/ZSmooth/zsmooth.dll")
  core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/libmvtools.dll")
  core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/DePan.dll")
  import stabilize
  clip = core.std.SeparateFields(clip, tff=True)
  height = clip.height
  clip = core.resize.Bicubic(clip, height=height*2)
  clip = stabilize.Stab(clp=clip, dxmax=0, dymax=1, range=1)
  clip = core.resize.Bicubic(clip, height=height)
  clip = core.std.DoubleWeave(clip, tff=True)
  clip = core.std.SelectEvery(clip, 2, 0)
  clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
  return [clip]
# defining beforeDeCross-function - END

# Import scripts
import vs_temporalfix
import fromDoom9
import SpotLess
import qtgmc
import validate
# Source: 'C:\Users\Selur\Desktop\1-source.mkv'
# Current color space: YUV420P8, bit depth: 8, resolution: 704x480, frame rate: 29.97fps, scanorder: top field first, yuv luminance scale: limited, matrix: 470bg, transfer: bt.601, primaries: bt.601 ntsc, format: mpeg-2
# Loading C:\Users\Selur\Desktop\1-source.mkv using DGSource
clip = core.dgdecodenv.DGSource("J:/tmp/mkv_43360fd7b44504b5cea6a7b5fab0c634_853323747.dgi",fieldop=0)# 29.97 fps, scanorder: top field first
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_BT601), if it is not set.
if validate.transferIsInvalid(clip):
  clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
# 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 29.97fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=30000, fpsden=1001)
# making sure the detected scan type is set (detected: top field first)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff
[clip] = beforeDeCross(clip)
# clip current meta; color space: YUV420P8, bit depth: 8, resolution: 704x480, fps: 29.97, color matrix: 470bg, yuv luminance scale: limited, scanorder: top field first, full height: true
# Deinterlacing using QTGMC
clip = qtgmc.QTGMC(Input=clip, Preset="Fast", TFF=True, opencl=True) # new fps: 59.94
# Making sure content is preceived as frame based
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
# Spot removal using SpotLess
clip = SpotLess.SpotLess(clip=clip, radT=3, rec=True, pel=1, smoother="zsmooth")
# removing flickering using ReduceFlicker
clip = core.rdfl.ReduceFlicker(clip=clip, strength=3, aggressive=1)
# removing flickering using Small Deflicker
clip = fromDoom9.Small_Deflicker(clip=clip, preset=3, cnr=True, zsmooth=True)
# changing range from limited to full range for vsTemporalfix
clip = core.resize.Bicubic(clip, format=vs.YUV420P8, range_in_s="limited", range_s="full")
# setting color range to PC (full) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
# stabilizing using Temporalfix
clip = vs_temporalfix.vs_temporalfix(clip=clip)
# changing range from full to limited range for vsTemporalfix
clip = core.resize.Bicubic(clip, format=vs.YUV420P8,range_in_s="full", range_s="limited")
# setting color range to TV (limited) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_LIMITED)
# adjusting output color from: YUV420P8 to YUV420P10 for NVEncModel
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10)
# set output frame rate to 59.94fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=60000, fpsden=1001)
# output
clip.set_output()
does seem to work. (I also added deflickering&co for stabilization and SpotLess for cleanUp.)
=> https://www.mediafire.com/file/qo0zawd6h...2.mkv/file

The custom code I used:
core.std.LoadPlugin(path="%FILTERPATH%/MiscFilter/MiscFilters/MiscFilters.dll")
core.std.LoadPlugin(path="%FILTERPATH%/DenoiseFilter/ZSmooth/zsmooth.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/libmvtools.dll")
core.std.LoadPlugin(path="%FILTERPATH%/Support/DePan.dll")
import stabilize
clip = core.std.SeparateFields(clip, tff=True)
height = clip.height
clip = core.resize.Bicubic(clip, height=height*2)
clip = stabilize.Stab(clp=clip, dxmax=0, dymax=1, range=1)
clip = core.resize.Bicubic(clip, height=height)
clip = core.std.DoubleWeave(clip, tff=True)
clip = core.std.SelectEvery(clip, 2, 0)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_TOP) # tff

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Messages In This Thread
Restoring badly digitized VHS - by Graven - 01.09.2025, 20:52
RE: Restoring badly digitized VHS - by Selur - 01.09.2025, 21:15
RE: Restoring badly digitized VHS - by Graven - 01.09.2025, 22:16
RE: Restoring badly digitized VHS - by Selur - 02.09.2025, 18:01
RE: Restoring badly digitized VHS - by Graven - 02.09.2025, 19:18
RE: Restoring badly digitized VHS - by Selur - 02.09.2025, 19:33
RE: Restoring badly digitized VHS - by Graven - 21.09.2025, 18:41
RE: Restoring badly digitized VHS - by Selur - 21.09.2025, 18:58
RE: Restoring badly digitized VHS - by Selur - 21.09.2025, 19:32
RE: Restoring badly digitized VHS - by Graven - 21.09.2025, 21:54
RE: Restoring badly digitized VHS - by Selur - 22.09.2025, 15:59
RE: Restoring badly digitized VHS - by Graven - 23.09.2025, 19:48
RE: Restoring badly digitized VHS - by Selur - 23.09.2025, 20:01
RE: Restoring badly digitized VHS - by Graven - 23.09.2025, 20:26
RE: Restoring badly digitized VHS - by Selur - 23.09.2025, 20:51
RE: Restoring badly digitized VHS - by Graven - 26.09.2025, 22:30
RE: Restoring badly digitized VHS - by Selur - 27.09.2025, 00:33

Forum Jump:


Users browsing this thread: 1 Guest(s)