Code:
import vapoursynth as vs
from vapoursynth import core
import subprocess
import ctypes
NVEnc = r'E:\VideoTest\TestSubs\NVEncC64.exe'
source_path=r'E:\VideoTest\TestSubs\TestVideo.mp4'
#Loading Plugins
core.std.LoadPlugin(path="E:/VideoTest/TestSubs/BestSource.dll") #from https://forum.doom9.org/showthread.php?t=184255
#current color space: YUV420P8, bit depth: 8
#resolution: 1280x536, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
#this clip is not not needed, just to get width and height
clip = core.bs.VideoSource(source=source_path)
w = clip.width
h = clip.height
bitdepth=8
Ysize = w * h * bitdepth // 8
Usize = w * h//4 * bitdepth // 8
Vsize = w * h//4 * bitdepth // 8
frame_len = Ysize + Usize + Vsize #YUV420
nvenc_filters = [
'--vpp-pmd apply_count=3,strength=100,threshold=100',
'--vpp-unsharp radius=4,weight=0.5,threshold=10',
'--vpp-smooth quality=3,qp=60,prec=fp32',
'--vpp-tweak brightness=0.01,contrast=1.01,gamma=0.98,saturation=0.90,hue=-2,swapuv=false',
'--vpp-deband range=15,sample=1,thre=15,dither=15,seed=1234,blurfirst=off,rand_each_frame=off',
]
command = [NVEnc,
'--avhw',
'--input "'+source_path+'" '
'-c raw',
' '.join(nvenc_filters),
'--output-res '+str(w)+'x'+str(h),
'--output-csp yuv420',
'--output-depth '+str(bitdepth),
'--output-format raw',
'--output -',
]
command = ' '.join(command)
pipe = subprocess.Popen(command, stdout = subprocess.PIPE, bufsize=frame_len)
def load_frame_from_pipe(n,f):
vs_frame = f.copy()
try:
for i, size in enumerate([Ysize, Usize, Vsize]):
ctypes.memmove(vs_frame.get_write_ptr(i), pipe.stdout.read(size), size)
pipe.stdout.flush()
except Exception as e:
raise ValueError(repr(e))
return vs_frame
try:
clip = core.std.ModifyFrame(clip, clip, load_frame_from_pipe)
except ValueError as e:
pipe.terminate()
print(e)
clip.set_output()
Hybrid has already all the components necessary to build the preview.
What was missing was the script to obtain the preview with Vapoursynth.
I hope that you will reconsider the possibility to include this feature in Hybrid.