MKV & MP4 Sources

Videos that are in MKV and MP4 containers are digitally distributed and are often a third generation encode that has already been run through filters to correct any major source related visual flaws. Any remaining defects in these video files are typically from the encode or are not correctable. The usual artifacts you may encounter include mosquito noise, minor macroblocking, and color banding. Since these sources have typically already been run through filters it is recommended that you avoid deblocking and spatial smoothing as that will blur the image and degrade the overall quality more. MDegrain, which is part of MVTools, can reduce mosquito noise and minor macroblocking artifacts while preserving details and Flash3kyuu Deband is recommended to handle any banding. Hysteria is suggested to resharpen the edges and lines that become blurred after applying these filters. Below is an example of these visual defects and an AviSynth script that addresses them.

(NOTE: Some quality issues in the sample images may not be as noticeable on small screens, viewing the sample images on a large screen is recommended.)

AviSynth Script Example

#Input video
LWLibavVideoSource("Video.mkv", format="YUV420P8")
#Removes light noise and minor blocking by reading two frames back and ahead
super = MSuper(pel=2, sharp=1)
backward_vec2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
backward_vec1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
forward_vec1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
forward_vec2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400)
#Removes banding by dithering
Flash3kyuu_deband()
#Sharpens lines and edges
Hysteria()

VapourSynth Script Example

#Initialize VapourSynth
import vapoursynth as vs
core = vs.get_core()
#Import Sharpening Script
import hysteria as hys
#Input video
video = core.lsmas.LWLibavSource(r'video.mkv', format="YUV420P8")
#Removes light noise and minor blocking by reading two frames back and ahead
super = core.mv.Super(video, pel=2, sharp=1)
backward_vec2 = core.mv.Analyse(super, isb = True, delta = 2, overlap=4)
backward_vec1 = core.mv.Analyse(super, isb = True, delta = 1, overlap=4)
forward_vec1 = core.mv.Analyse(super, isb = False, delta = 1, overlap=4)
forward_vec2 = core.mv.Analyse(super, isb = False, delta = 2, overlap=4)
video = core.mv.Degrain2(video, super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thsad=400)
#Removes banding by dithering
video = core.f3kdb.Deband(video)
#Sharpens lines and edges
video = hys.Hysteria(video)
#Sets Video Output
video.set_output()