Log in

View Full Version : How do I load DGIndex file with VapourSynth and resize the video?


orion44
27th August 2023, 22:18
What are the equivalent VapourSynth commands of the following AviSynth script:

LoadPlugin("C:\DGDecNV\DGDecodeNV.dll")
#LoadPlugin("C:\Program Files (x86)\AviSynth\plugins\ColorMatrix.dll")
DGSource("D:\Project\m2ts.dgi")
#ColorMatrix(mode="Rec.709->Rec.601")
Crop(4,0,1916,1080)
BlackmanResize(1280,720)
#Lanczos4Resize(1280,720)
#Spline36Resize(716,404)
#Spline64Resize(716,404)
SelectRangeEvery(2880,144)
#Trim(6982,7330) ++ Trim(8520,9440)

I want to: load dgi file, crop it, and then resize it.

Selur
28th August 2023, 09:09
untested:

#core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll") # only if not auto-loaded
#core.std.LoadPlugin(path="F:/Hybrid/64bit/vsfilters/Support/fmtconv.dll") # only if not auto-loaded
clip = core.dgdecodenv.DGSource("D:\Project\m2ts.dgi")
#clip = core.resize.Bicubic(clip=clip, matrix_in_s="709", matrix_s="470bg")
clip = core.std.CropAbs(clip=clip, left=4, top=0, right=1, width=1916, height= 1080)
clip = core.fmtc.resample(clip=clip, kernel="blackman", w=1280, h=720)
#clip = core.fmtc.resample(clip=clip, kernel="lanczos", w=1280, h=720)
#clip = core.fmtc.resample(clip=clip, kernel="spline36", w=716, h=404)
#clip = core.fmtc.resample(clip=clip, kernel="spline64", w=716, h=404)
clip = core.std.SelectEvery(clip = clip, cycle = 2880, offsets = range(144))
# clip = core.std.Trim(clip,6982,7330) + core.std.Trim(clip,8520,9440) # untested
return clip

orion44
28th August 2023, 10:02
Thanks, I'll test it.

_Al_
12th September 2023, 03:31
How about make indexing in the same script or index for bunch of sources beforehand, I do not have nvidia, cannot test it:

import vapoursynth as vs
from vapoursynth import core
from pathlib import Path
import os
from concurrent import futures

dgindexnv_dir = r"F:\downloads\dgdecnv_248"

SETTINGS = {
'dgindexnv_kwargs' : {},
'dgindexnv_options' :" -e ",
'dgindexnv_indexes_dir' : r"G:\indexes",
'exe_path' : str(Path(dgindexnv_dir) / 'DGIndexNV.exe')
}

core.std.LoadPlugin(str(Path(dgindexnv_dir) / 'DGDecodeNV.dll'))

def run_indexing(source, settings):
dgi_file = str(Path(settings['dgindexnv_indexes_dir']) / f'{Path(source).stem}.dgi')
if Path(dgi_file).is_file():
return dgi_file
cmd = f'title DGIndexNV creating: "{dgi_file}" | "{settings["exe_path"]}" -i "{source}" -o "{dgi_file}" {settings["dgindexnv_options"]}'
print(cmd)
return_code = os.system(cmd)
if not return_code and Path(dgi_file).is_file():
return dgi_file
else:
print(f'failed indexing for: "{source}"')
return ''

#getting indexes done beforehand for a bunch of files if needed
sources = [r"G:\video.mp4",] #could be one source or many
with futures.ThreadPoolExecutor(max_workers=8) as exe:
jobs = [exe.submit(run_indexing, source, SETTINGS) for source in sources]
indexes = [job.result() for job in jobs]

#getting a clip for a source
source = r"G:\video.mp4"
dgi_file = str(Path(SETTINGS['dgindexnv_indexes_dir']) / f'{Path(source).stem}.dgi')
if not Path(dgi_file).is_file():
run_indexing(source, SETTINGS)
clip = core.dgdecodenv.DGSource(dgi_file, **SETTINGS["dgindexnv_kwargs"])
clip.set_output()

does it work?