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 videoLWLibavVideoSource("Video.mkv", format="YUV420P8")#Removes light noise and minor blocking by reading two frames back and aheadsuper = 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 ditheringFlash3kyuu_deband()#Sharpens lines and edgesHysteria()VapourSynth Script Example
#Initialize VapourSynthimport vapoursynth as vscore = vs.get_core()#Import Sharpening Scriptimport hysteria as hys#Input videovideo = core.lsmas.LWLibavSource(r'video.mkv', format="YUV420P8")#Removes light noise and minor blocking by reading two frames back and aheadsuper = 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 ditheringvideo = core.f3kdb.Deband(video)#Sharpens lines and edgesvideo = hys.Hysteria(video)#Sets Video Outputvideo.set_output()