Log in

View Full Version : Median Filter - Glitches Only In Encoded Video?


ENunn
3rd October 2024, 06:49
i'm trying to use the median filter to stack three captures of a betacam tape. the preview in avspmod looks fine, but the encoded video has visual glitches and i don't know why. i'm only getting these on the encoded video. the glitches seem to show up at random, so every encode is different.

Raw:
https://i.imgur.com/Cj8xJlU.png
https://i.imgur.com/oB5GLxc.png

Encoded:
https://i.imgur.com/CBVwivW.png
https://i.imgur.com/BXmOyb2.png

i have tried both median and medianblend, both with the same result.

Script:
setmemorymax(63448)
v = lwlibavvideosource("I:\virtualdub\tape transfers\betacam\sp\Lot #3\LAIDLAW TRANSIT THE BUS STOPS HERE.mkv", fpsnum=30000, fpsden=1001)
a = lwlibavaudiosource("d:\recordings\LAIDLAW TRANSIT THE BUS STOPS HERE.flac")
audiodub(v,a)
Trim(228, 19744)
v1=last
AVISource("F:\virtualdub\tape transfers\betacam\sp\Lot #3\LAIDLAW TRANSIT THE BUS STOPS HERE cap 2.avi")
Trim(135, 19651)
v2=last
AVISource("F:\virtualdub\tape transfers\betacam\sp\Lot #3\LAIDLAW TRANSIT THE BUS STOPS HERE cap 3.avi")
Trim(357, 19873)
v3=last
medianblend(v1,v2,v3)
assumetff()
converttoyuv444(matrix="rec601", interlaced=true).convertbits(10)
Levels(70, 1, 990, 0, 1020, coring=false,dither=true).tweak(bright=0, cont=1.00, hue=-0, sat=1.0, coring=false, dither=true).convertbits(8)
Trim(1500, 19348)
qtgmc(preset="slow", ezdenoise=0.0, sharpness=0, sourcematch=3,lossless=2,matchenhance=1,tr2=0, subpel=4)
spotless()
finedehalo()
neo_dfttest(sigma=6, tbsize=3)
f3kdb(range=20, y=80, cb=80, cr=80, dynamic_grain=true)
cropresize(indar=15.0/11.0, resizewo=true)
Crop(5, 0, -6, -2)
SuperRes(matrixin="rec601", 2, .43, 0, """nnedi3_rpow2(4, nns=4, cshift="Spline16Resize")""", matrixout="rec709")
#SuperRes(2, .43, 0, """edi_rpow2(2, nns=4, cshift="Spline16Resize")""").SuperRes(2, .43, 0, """edi_rpow2(2, nns=4, cshift="Spline16Resize")""")
x = float(width) / float(height)
spline36resize(round(x * 2164),2164)
converttoyv12(matrix="rec709", interlaced=false)
prefetch(10)

ffmpeg command:
ffmpeg -i "script.avs" -pix_fmt yuv420p10le -c:v hevc_nvenc -gpu any -g 30 -rc vbr -qp 18 -qmin 18 -qmax 18 -b:v 0K -preset p7 -c:a copy "output.mkv"

is there a fix for this?

VoodooFX
8th November 2025, 12:41
Post what "AVSMeter64 -avsinfo" shows.
Try replacing AVISource with LWLibavVideoSource.

DTL
8th November 2025, 14:22
Is it median only issue ? Your script has lots of other filters and this looks like some multithreading issue in some filter or even AVS+ core or encoding software (ffmpeg).

Try minimal possible script to narrow the defect source. For median of 3 clips with fastest processing you can also try filters like

Interleave(tr1, src, tr2)
Clense() (or MedianBlurTemporal(radiusy=0, radiusu=0, radiusv=0, temporalradius=1) or vsTTempSmooth(pmode=1,..) )
SelectEvery(3, 1)

So if you expect your median filter cause issues - you can test at least 3 different implementations to look if some of 3 may work for you. If 3 different median filters return same random errors - it may be something else (up to host hardware issues).

Short green line on black may be zeroed YUV memory area (as usual).