Skip to content

Instantly share code, notes, and snippets.

@lextra2
Last active October 18, 2025 05:47
Show Gist options
  • Save lextra2/11106c55561c8d45c5601b90fee33f5a to your computer and use it in GitHub Desktop.
Save lextra2/11106c55561c8d45c5601b90fee33f5a to your computer and use it in GitHub Desktop.
AVISYNTH-2022
LWLibavVideoSource("C:\Users\ULTRA\Downloads\ffmpeg\06.mkv").Prefetch(0)
DeBilinearResizeMT(1280, 720).Prefetch(0)
z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:limited=>rgb:709:709:full", dither_type="error_diffusion", cpu_type="avx2", use_props=0).Prefetch(0)
mlrt_ort(network_path="C:\Program Files (x86)\AviSynth+\plugins64+\mlrt_ort_rt\models\2x_Ani4Kv2_G6i2_Compact_107500_fp32.onnx", builtin=False, provider="DML", fp16=True, num_streams=1).Prefetch(2)
z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:full=>709:709:709:limited", dither_type="error_diffusion", cpu_type="avx2", use_props=0).Prefetch(0)
LWLibavVideoSource("C:\Users\ULTRA\Downloads\ffmpeg\06.mkv").Prefetch(0)
z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:limited=>rgb:709:709:full", dither_type="error_diffusion", cpu_type="avx2", use_props=0).Prefetch(0)
RIFE(model=68, model_path="C:\Program Files (x86)\AviSynth+\plugins64+\rife-v4.24_ensembleTrue").Prefetch(2)
z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:full=>709:709:709:limited", dither_type="error_diffusion", cpu_type="avx2", use_props=0).Prefetch(0)
LWLibavVideoSource("C:\Users\ULTRA\Downloads\ffmpeg\OVA.mkv").Prefetch(0)
ConvertBits(32).Prefetch(0)
BM3D_CUDA(radius=2).Prefetch(8)
BM3D_VAggregate(radius=2).Prefetch(8)
ConvertBits(16).Prefetch(0)
ConvertBits(10, dither=0).Prefetch(0)
LWLibavVideoSource("C:\Users\ULTRA\Downloads\ffmpeg\OVA.mkv").Prefetch(0)
EZdenoise(Chroma=true).Prefetch(11)
# EZdenoise v5
function EZdenoise(clip Input, int "thSAD", int "thSADC", int "TR", int "BLKSize", int "Overlap", int "Pel", bool "Chroma", bool "out16", int "Plane")
{
thSAD = default(thSAD, 150)
thSADC = default(thSADC, thSAD)
TR = default(TR, 3)
BLKSize = default(BLKSize, 8)
Overlap = default(Overlap, 4)
Pel = default(Pel, 1)
Chroma = default(Chroma, True)
out16 = default(out16, False)
# Ternary operator to avoid using UV planes, when Chroma is set to "False".
Plane = Chroma ? 4 : 1
Super = Input.MSuper(Pel=Pel, Chroma=Chroma)
Multi_Vector = Super.MAnalyse(Multi=True, Delta=TR, BLKSize=BLKSize, Overlap=Overlap, Chroma=Chroma)
Input.MDegrainN(Super, Multi_Vector, TR, thSAD=thSAD, thSAD2=int(float(thSAD*0.9)), thSADC=thSADC, thSADC2=int(float(thSADC*0.9)), out16=out16, Plane=Plane)
}
LWLibavVideoSource("C:\Users\ULTRA\Downloads\ffmpeg\S01E01.mkv", cache=false).Prefetch(0)
QTGMC(Preset="Very Slow", Sharpness=1.0, FPSDivisor=2).Prefetch(9)
z_ConvertFormat(pixel_type="RGBPS", colorspace_op="601:601:170m:limited=>rgb:709:709:full", dither_type="ordered", cpu_type="avx2", use_props=0).Prefetch(0)
mlrt_ort(network_path="C:\Program Files (x86)\AviSynth+\plugins64+\mlrt_ort_rt\models\2x_AniSD_AC_G6i2a_Compact_72500_fp32.onnx", builtin=False, provider="DML", fp16=True, num_streams=1).Prefetch(2)
z_ConvertFormat(height=1080, pixel_type="YUV420P8", colorspace_op="rgb:709:709:full=>709:709:709:limited", dither_type="error_diffusion", cpu_type="avx2", use_props=0).Prefetch(0)
LWLibavVideoSource("C:\Video\SPONGEBOB_DISC1_NTSC\D3_t02.mkv")
tfm(slow=2, mChroma=false)
tdecimate(mode=1)
MPEG2Source("C:\Users\Admin\Downloads\New folder\E3_t06.d2v")
TFM(d2v="C:\Users\Admin\Downloads\New folder\E3_t06.d2v", slow=2, mode=5)
TDecimate(mode=1)
Crop(6, 0, -6, -0)
Spline36Resize(720, 540)
FFT3DFilter(sigma=10, bt=5, bw=32, bh=32, ow=16, oh=16, plane=3)
Autolevels(filterRadius=30).Levels(0, 1, 255, 0, 235)
Prefetch(4)
ConvertBits(32).ConvertToPlanarRGB()
mlrt_ort(network_path="C:\Program Files (x86)\AviSynth+\plugins64+\models2\2x_Garfieldjr_span48.onnx", builtin=false, provider="dml")
#4445
#7590
function ShowMe(clip Input)
{
Super = Input.MSuper(hpad=0, vpad=0, pel=1)
Vector = MAnalyse(Super)
MShow(Super, Vector, showsad=true)
}
LWLibavVideoSource("C:\Users\Admin\Downloads\New folder\S01E01.mkv")
global c = last
global n = DoubleWeave(c).SelectOdd()
global p = DoubleWeave(c).SelectOdd().DuplicateFrame(0)
global c = VMAF2(c,vinverse(c),feature = 0)
global n = VMAF2(n,vinverse(n),feature = 0)
global p = VMAF2(p,vinverse(p),feature = 0)
c
ScriptClip("""
n_metric = propGetFloat(n,"psnr_y") + propGetFloat(n,"psnr_cb") + propGetFloat(n,"psnr_cr")
c_metric = propGetFloat(c,"psnr_y") + propGetFloat(c,"psnr_cb") + propGetFloat(c,"psnr_cr")
p_metric = propGetFloat(p,"psnr_y") + propGetFloat(p,"psnr_cb") + propGetFloat(p,"psnr_cr")
n_metric > c_metric && n_metric > p_metric ? n : \
p_metric > c_metric && p_metric > n_metric ? p : c
""")
@lextra2
Copy link
Author

lextra2 commented Nov 27, 2020

@lextra2
Copy link
Author

lextra2 commented Jan 1, 2021

@lextra2
Copy link
Author

lextra2 commented May 30, 2022

ffmpeg -y -benchmark -init_hw_device opencl=GPU -filter_hw_device GPU -i INPUT.mkv -c:v prores_ks -filter_complex "format=yuv420p, hwupload, nlmeans_opencl, hwdownload, format=yuv420p" -q:v 4 -an -frames 480 OUTPUT.mkv

Note: Much slower and much worse quality over MVtools. Do not use!

ffmpeg -y -benchmark -init_hw_device vulkan -i INPUT.mkv -vf "format=nv12,hwupload,nlmeans_vulkan,hwdownload,format=nv12" -c:v libx264 OUTPUT.mkv

@lextra2
Copy link
Author

lextra2 commented Jul 16, 2023

ffmpeg -y -benchmark -i 02.mkv -c:v prores_ks -q:v 4 -vf "dejudder, fps=30000/1001, fieldmatch=mode=pcn_ub:combmatch=full, yadif=deint=interlaced, decimate" -c:a copy 002.mkv

@lextra2
Copy link
Author

lextra2 commented Nov 7, 2024

@lextra2
Copy link
Author

lextra2 commented Sep 9, 2025

https://forum.doom9.org/showthread.php?p=1998906#post1998906

https://github.com/Asd-g/avs-mlrt/releases/tag/r63

DON'T USE FUCKING CUDA. ITS FUCKING SLOOOWWWW.

For 16GB GPUs, use fp16=true for 1080p > 2160p

  • dml_dll.7z
  • mlrt_ort-1.0.1.7z
  • onnxruntime_dll.7z

mlrt_ort_rt

Avisynth_01 Avisynth_02

@lextra2
Copy link
Author

lextra2 commented Sep 9, 2025

Avisynth RIFE
RIFE Models
Note: ensemble=True is quality oriented.
Note2: Model 4.25 is supposedly the best. ("Heavy" are shit)

RIFE_setup

@lextra2
Copy link
Author

lextra2 commented Sep 9, 2025

NTSC DVD to Blu-ray:

z_ConvertFormat(colorspace_op="601:601:170m:limited=>709:709:709:limited")

709 to RGB 32bit to YUV 8bit

z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:limited=>rgb:709:709:full")
z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:full=>709:709:709:limited")

ConvertToPlanarRGB(matrix="709:limited").ConvertBits(32)

PAL DVD to Blu-ray:

z_ConvertFormat(colorspace_op="470bg:601:470bg:limited=>709:709:709:limited")

@lextra2
Copy link
Author

lextra2 commented Sep 9, 2025

OLD - Descale
NEW - Descale (FASTEST)
DOCS
Guide

Descale Vapoursynth

Avsresize Docs (z_ConvertFormat)
Avsresize NEWEST
Note: The default for resizing is resample_filter="bicubic", filter_param_a=0.0, filter_param_b=0.5

The following avoids hitting color-shift from swscale in ffmpeg:
-vf "zscale=rin=limited:pin=709:tin=709:min=709:r=limited:p=709:t=709:m=709"

Libplacebo can be used to format conversion, too:
-vf "libplacebo=format=yuv420p"

Probably related issue

@lextra2
Copy link
Author

lextra2 commented Sep 19, 2025

ffmpeg -y -benchmark -i INPUT.mkv -c:v utvideo -vf "libplacebo=w=iw*2:h=ih*2:custom_shader_path=SHADER.glsl" -an -frames 480 OUTPUT.mkv

ffmpeg -y -benchmark -i 06.mkv -c:v utvideo -vf "libplacebo=deband=1:deband_threshold=0:deband_grain=32:custom_shader_path=adaptive-sharpen.glsl" -frames 48 TEST.mkv

@lextra2
Copy link
Author

lextra2 commented Sep 24, 2025

Downsize luma only, keep chroma as is

MPEG-4 chroma location:

Y = ConvertToY8(matrix="XXX").DeBilinearResizeMT(1920, 1080, src_left=0, src_top=0)
U = UToY8()
V = VToY8()
YToUV(U, V, Y)

@lextra2
Copy link
Author

lextra2 commented Sep 28, 2025

@lextra2
Copy link
Author

lextra2 commented Oct 2, 2025

QTGMC(Preset="Very Slow", Sharpness=0, FPSDivisor=2, SubPel=1, BlockSize=8, Overlap=4, thSAD1=256, SourceMatch=3, Lossless=2, MatchPreset="Very Slow", MatchPreset2="Very Slow").Prefetch(11)

@lextra2
Copy link
Author

lextra2 commented Oct 16, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment