This guide helps you use TSPAN with TensorRT for accelerated video upscaling.
- Set up VapourSynth following pifroggi's guide, sections 1 and 2
- Download and extract
vsmlrt-windows-x64-tensorrt.[version].7zfrom vs-mlrt releases to yourvs-pluginsdirectory - Get the model:
- Download pre-converted ONNX from releases, or
- Convert your own using
convert_to_onnx.py(see script for detailed options)
-
Build TensorRT engine using
trtexec:FP16:
trtexec --onnx="tspan_fp16.onnx" --fp16 --optShapes=input:1x15x720x1280 --inputIOFormats=fp16:chw --outputIOFormats=fp16:chw --saveEngine=tspan_fp16.engine --builderOptimizationLevel=5 --useCudaGraph --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LTFP32:
trtexec --onnx="tspan_fp32.onnx" --optShapes=input:1x15x720x1280 --saveEngine=tspan_fp32.engine --builderOptimizationLevel=5 --useCudaGraph --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LT -
Copy
vapoursynth_script.pyto your VapourSynth directory, then configure it with your video path and engine path -
Open a Command Prompt window (NOT POWERSHELL) in your VapourSynth directory, then run a command like this. Customize the encoder settings as you wish:
vspipe -c y4m ".\vapoursynth_script.vpy" - | ffmpeg -i - -c:v hevc_nvenc -qp 0 -preset p5 -tune lossless "output.mkv"