I Have been trying to develop an avisynth script that could prove useful for restoring my vhs captures and could be used in the majority of them without extensive tweaks or modifications.
My know how on avisynth itself and itīs many plug-inīs itīs however still limited , so there may be errors, namely Incorrect filters choice, incorrect relative filters positioning , incorrect settings and the like. Also I still donīt clearly identify all video type problems present on the sources, so some problems are eventually not addressed as I donīt identify their presence or I donīt know what they are.
However I have done my best with my present know how and even if the script is not totaly optimized and revised I think it gives already interesting results.I have tried it in several different vhs sources and it always provide a significant improvement obviously better in some than in others.
Script- The script is a MT version ( using avisynth 2.6 MT and some modded plug-inīs) however even if it seems to works fine with no errors I can not use SetMTmode (2) or (2,0) after loading the video source ,any attempt to do so results in a crash. Not using it I do have a stable script running at about 5.5- 6 fps (6700k overclocked, 8 logical cores) what seems reasonable as the script is heavy as the settings quite aggressive , relaxing the settings a little I can easily get about 8-10 fps or better depending on the settings.
Problems-The more visible problem that I can still identify is a sort of ghost/ halo image, I donīt know exactly if due to over sharpening or some sort of vertical chroma ghost /bleeding /halo .I tried several approachīs DeHalo, DeGhost, FixVhsOversharp and several others, however none as fixed the problem some reduce it a little at the cost of significant detail loss. The only one that seems to give a very very small contribute without apparently affecting detail is the old filter FixVHSOversharp .Perhaps due to denoizer settings some areas seem a little blurred sometimes.
Denoizers- I have tried the more usual denoizers, Neat Video, MCTemporalDenoize, dfttest, EZdenoize, fft3dfilter, MDegrain2 (John Meyers implementation), DegrainMedian and HQDN3D. I think I got the best results from fft3dfilter but the difference is very small related to some of the others and the settings could have been more optimized for this one than for the others. If I do have an exceptionally good frame to do a good noise profile I got better results from Neat Video , however it could not be so generically applied as fft3dfilter and obliges me to do an additional color space conversion and to do individual separate source noise test, which makes things more difficult and less automatic .So for generic sources I think I prefer fft3dfilter and for some namely with more grain eventually Neat Video.Sometimes some areas seem a little Blurred I dont know if itīs from the denoizer or itīs settings or any other cause.
Deshaker- I have used Depan/DepanStabilize as they ease the script as I can do it in only one run without having to resort to virtualdub to get the necessary settings data . For not to problematics sources the results seems similar to Vdub Deshaker however I think that for more problematic shake sources Vdub deshaker provides better results.
Chroma Denoizer- I have tried CCD ( camcorder color denoizer) as it is usually considered better however I didnīt see a significant difference related to Cnr2 and to use it I have to do an additional color space conversion to RGB32, I will stick with Cnr2 perhaps not so good but prevents one color conversion so the results seems to be very similar.
Stabilizers- Before /after QTGMC and Depan/Depanstabilize is usually to use a stabilizer. I tried Stab and Stabmod ( lordsmurf version) but it seems I got better results with FluxSmooth that can be used in interlaced or progressive stuff however I donīt know for sure if I have made the correct use of it.
Sharpen I have tried Sharpen, SSSharp and UnsharpHQ for me it seems the last one provided the best results
Levels / color correction I have tried colorYUV, autolevels and Tweak. ColorYUV doesnt seem to work well for me ,however autolevels and Tweak worked fine but I think autoadjust and SmoothTweak provide better results.
Hoping to have your comments, reviews about this script to try to improve and optimize it if possible and to solve some of the remaining problemsCode:SetMTMode(5,8) SetMemoryMax(1024) #LoadVirtualDubPlugin("c:\Program Files\Virtualdub 1.9.11\Plugins\ccd.vdf", "ccd",1) AviSource("E:\New captures\capture1.avi").AssumeTFF() #SetMTMode(2,0) # crash with setMTmode(2) and (2,0) Crop(8, 8, -8, -12) #Tweak(sat=1.1 , bright=0 ,cont=1) # YUV2 tweak vs SmoothTweak FixVHSOversharpL(30,12,8) # (YUV2) not absolutely sure about eventual benefit #ConvertToRGB32(matrix="Rec601",interlaced=true) # update matrix Pc.601(0-255)/Rec601(16-235) # alternative deshaker virtualdub plug-in "Deshaker " # alternative denoize "neat video" ### Chroma noise ### #CCD(30,1) # (RGB32) separatefields() Cnr2("oxx",8,16,191,100,255,32,255,false) # (progressive YUV2/YV12) vs CCD HDRAGC(coef_gain=0,8 ,coef_sat=1 ) # (YUV2/YV12 progressive) , High Dynamic Range Automatic Gain Control weave() ChromaShift(C=-4,L=-2) # (RGB32, YUY2, YV12) align chroma over luma #Autolevels(filterRadius=7, autolevel=true, autogamma=false) # (YUV2/RGB/YV12, seems to works better in RGB) autolevels vs autoadjust ConvertToYV12(matrix="Rec601",interlaced=true) # update matrix Pc.601(0-255)/Rec601(16-235) ### Deinterlace ###(YV12 YUY2) FluxSmoothT(temporal_threshold=6) # (YUY2, YV12 progressive/interlaced ), not sure about which stabilizer to use QTGMC( Preset="Slower", EdiThreads=4, SourceMatch=3, MatchPreset="Slower", MatchPreset2="Slower",TR2=2, Lossless=2, MatchEnhance=0.8) FluxSmoothT(temporal_threshold=6) #Stab(range=3, dxmax=15, dymax=15, mirror=0) # (YV12 Progressive) santiag(strh=2,strv=2,type="nnedi3",nns=4,scaler_post="Spline64Resize",threads=8) # (YV12 Progressive), antialiasing ### Denoiser #### # Denoise UV (YUY2, YV12) fft3dfilter(sigma=2.5,sigma2=4.0,sigma3=3.5,sigma4 =8, bt=2, bw=16, bh=16, ow=8, oh=8,plane=3, sharpen=0.0,interlaced=true,dehalo=1.0, hr=6.0, ht=50.0,ncpu=8) # U= Blue V= green # Denoise Y ( Luma) , (YUY2, YV12) fft3dgpu(bt=3,sigma=4.0,sigma2=4.0,sigma3=3.5,sigma4=8,bw=32,bh=32,ow=16,oh=16,sharpen=0,plane=0,mode=1,precision=2,interlaced=true) GradFun3 () # to reduce colorbanding ### Alternatives Denoizers ### #QTGMC( Preset="Slower", NoiseProcess=1, NoiseRestore=0.0, Denoiser="dfttest", DenoiseMC=true, SourceMatch=3, Sharpness=0.5, TR2=2, Lossless=2, MatchEnhance=0.75, Sigma=4) #QTGMC( Preset="Slower", EZDenoise=1.5, NoisePreset="Slow", DenoiseMC=true, SourceMatch=3, Sharpness=0.5, TR2=2, Lossless=2, MatchEnhance=0.75, NoiseProcess=1, NoiseRestore=0.5, Sigma=2.5) #MCTemporalDenoise(settings="low", thSAD=256, thSCD1=256, radius=2 , sigma=5 , bwbh=32, owoh=4, blksize=8, overlap=4, maxr=4 ,TTstr=3 , adapt=true, protect=true, enhance=false, truemotion=true, stabilize=true, chroma=true, gpu=true) # johnmeywer MDegrain2 script , DegrainMedian #hqdn3d(ls=5.0, cs=3.0, lt=7.0, ct=4.5, restart=8) MergeChroma(Spline64Resize(width/4, height).aWarpSharp2(depth=10).Spline64Resize(width,height)) # progressive - sharpens chroma ### Deshake ### Depan or Virtualdub Deshake maxstabH=40 maxstabV=30 mdata=DePanEstimate(last,trust=1.0,dxmax=maxstabH,dymax=maxstabV) DePanStabilize(last,data=mdata,dxmax=maxstabH,dymax=maxstabV,method=1,mirror=15,cutoff=1.0,damping=1.0,prev=0,next=0,blur=0) FluxSmoothST(temporal_threshold=7, spatial_threshold=7) # ST progressive #SelectEvery(3, 1) # if used change the speed from 5 fps to 1.5 fps ? ### levels, color adjustment ### AutoAdjust(high_quality=true, threads_count=8) SmoothTweak(HQ=true, saturation=1.2, contrast=1.1, brightness=-13, useMT=1) #useMT=1 ### Sharpen ### UnsharpHQ(THRESHOLD=20, SHARPSTR=4.0, SMOOTH=0.9, SHOW=false) #SSSharp(ssw=true, iter=2, strength=3) # vs unsharpHQ #Deen(mode="c3d", rad=3, thrY=20, thrUV=12, tthY=4, tthUV=6, min=0.5, scd=9.0, fcf="", borderfix=false) #DeHalo_alpha(rx=2, ry=1,brightstr =0.9 ) # if needed but detail could suffer Spline64Resize(720, 576) SetMTMode(1) GetMTMode(false) > 0 ? distributor() : last
attached - noise profile sample
+ Reply to Thread
Results 1 to 11 of 11
Last edited by FLP437; 11th Dec 2016 at 20:37.
Wow, that script sure has a lot going on. Are you really using ALL of those plugins on one poor video??
Here are my brief comments as I read through the script.
Don't crop before doing motion stabilization. Crop afterwards so the crop will not only hide the overscan junk, but also the stabilization borders. Also, add back borders after cropping rather than re-sizing, unless you don't mind adding re-sizing artifacts. Cropping and then re-sizing to a larger size will simply make the video look more blurry.
I think CNR can work directly on interlaced material, so I don't think there is a need to seperatefields()/weave().
I don't know FixVHSOversharp, but it doesn't sound like something that is needed. In fact, I wonder if sharpening is needed with VHS. I seldom use it. You also have other sharpening steps.
Chroma shifting is usually only needed when you have a copy of a copy.
You have a LOT of noise reduction. I'm not sure I've ever seen so many noise reduction steps: FluxSmooth, QTGMC; Fluxsmooth (again!); and then FluxSmoothST (you seem to like FluxSMooth), santiag (whatever that is), fft3DFilter AND fft3DGPU (why do you use both??). By my count that is seven separate noise reduction plugins. I see absolutely no reason to use so many noise reduction plugins. Start with one and use only that one single plugin (you seem familiar with my VHS script, so you know I use MDegrain2). Then, if there is still an artifact to remove, you can consider using something else. Most scripts that use more than one noise reduction plugin use a spatial and then a temporal denoiser (or is it the other way around?).
Finally, I downloaded your Clip_test.avi, and it sure doesn't look like a VHS video capture. It also looks like it has already been heavily processed. I'm not at my main editing computer that has all sorts of analysis tools, but when viewing it using VLC it looks to have some significant temporal issues, probably from some sort of of plugin or script that has done something wrong.
I just looked at your "restored" clip and, not surprisingly, you have removed a huge amount of detail. As one example, the grass on the hillside is now just a flat green splotch.
As I've said dozens of times in other posts, the mantra when doing restoration is "less is more." In other words, don't over-do it.
Perhaps others can provide more ideas.
- My sister Ann's brother
Thanks Johnmeyer your contibutes are always very usefull . Yes I also do feel that the script is too heavy but I have I been adding one step after another and as each one for me seemed to add value I let them stack up in the script ,so I have to try to simplify a little.
Related to Cnr2 I have used it that way as it is stated in the avisynth wiki thats only progressive . However it does seem to work in interlaced stuff at least it doesnīt give any errors.
FixVHSoversharp doesnīt real add significant value has I already have commented in the script itself and itīs a very old filter however from the several I tried to get rid of vertical ghost it has been the only one not to crush detail and seemed to give a minor benefit but obvious is not an important part of the process.
Chroma shifting I have used it exactly because the source is a copy . I have several vhs tapes that are copies from video8/hi8/minidv but I only have the VHS tapes not the originals that were from third persons.
Related to noise reduction I hope I dont have so many cumulative denoizers or at least the idea was not that one, Fluxsmooth I have used it several times in the script as I have saw several script examples were stab() were used just before and after QTGMC and Depan/Depanstabilize also in itīs examples do use a stabilizer at the end ( fluxsmooth) . At least one before or probably after QTGMC I also dont see an advantage the other 2 I dont know for sure I have to retest again. However I have choose this one exactly because it is said to be very good to preserve detail and for me seems to works better than stab() and many docs refers the importance of stabilizers before or after QTGMC and or Depan/DepanStabilize but itīs an area that I have to clarify and retest and all informtion is welcome.
QTGMC I have eliminated all noise processing eventually it still will do any denoizing but if does it should be minimum. fft3dfilter and fft3dgpu are not two denoiser one after another as each one is acting only in one color plane one in luma and the other in chroma the idea is only to have a more efficient and fast filter it could have be done only with one instance.
Related to the source clip yes it is a direct s-video capture not pre processed , however I will redo the capture as the only hypothesis is that I somewhat have confounded my multiple test source very unlikely but not impossible.
edit:Related to the SetMtmode(2) crash and the vertical halo that do subsist do you have any ideas ? thanks
Last edited by FLP437; 11th Dec 2016 at 20:17.
I looked at the original clip on my editing computer, and there is no temporal issue. That problem was on my laptop.
Here is a still image showing one field from the original, and the same field after processing by your script (i.e., "restored.avi"). The original is on top. I always look at fields when dealing with interlaced video in order to not get fooled by having images which contain information from two distinct points in time.
As I mentioned, all the detail in flat areas (like the grass in the upper left corner, the grass immediately behind the four people in the foreground, and the gravel in the bottom center) has been removed. That is a LOT of detail gone. You will also notice that the cursive writing on the side of the ski tow building, while indistinct in the original, still looks like you could almost read it. In the "restored" version, it has all been mushed together and just looks like a big blob.
I actually see so little noise that I'd be tempted to do no denoising whatsoever ("less is more") or at the most, some very, very light denoising using MDegrain2.
If you look at individual fields, and watch the black line along the roof of the ski tow, you will see that in the processed clip there are some pretty significant diagonal lines that appear because of the re-sizing. They are not very apparent in this particular clip, but are quite strong on other fields. As always, such artifacts depend on the exact location of the pixels, the angle of the line, and the exact scaling amount being used. This is why I recommended not doing any scaling. Also, as everyone can see, you have changed the aspect ratio and now have excess pillars on the side. You already had pillars in the original (did you already crop it?), but you definitely don't want to change the aspect ratio.
In general, the clip seems to already be a little too contrasty, and your script makes it even more so. Of course some of that is personal taste and preference, but at some point you will lose details in the shadows and highlights. That is already happening. For instance, if you look at the white t-shirt worn by the boy immediately to the right of the woman in red, the original shows some details, but the "restored" version has the highlights completely blown out, and all details are lost. I can give similar examples for various details in the shadows.
So, keep "ripping out the knitting" in your script until you reduce the script down to just the elements needed to reduce some of the noise. The sharpening did improve the lines on the green roof of the utility shed in the foreground (not seen in the above pic), but other than that it seemed to do nothing except increase contrast and add halos. As I said in my first post, before I actually viewed your clip field-by-field, I suspected that sharpening was not going to give you something better.
As for your chroma shift, the only place to test that code in this clip is on the woman's red shirt. It has shifted the chroma, but I think it has made things worse. The picture shows a little of the problem, but you'll see it more as you walk through the clip: you have actually created a chroma halo to the left of the woman that wasn't there before. I have seen this happen when I've attempted to shift the chroma. Generally you only want to shift two pixels to the left for a one-generation copy (i.e., a copy directly from the original).
Last edited by johnmeyer; 11th Dec 2016 at 21:27. Reason: added "(not seen in the above pic)"
FixVHSOversharpen works for halos on either the left or the right. You need to call both functions if you want to fix both:
FixVHSOversharpL(30,12,8) # fix halos on left FixVHSOversharp(30,12,8) # fix halos on right
Thank you johnmeyer and jagabo with your inputs the script itīs on itīs way to be a more efficient one.
any idea for the crash with SetMTmode (2)
As for chroma shift caused by multi-generation, it is a well-known issue. The following is not authoritative (although they guy is generally regarded as a guru), but I don't have time to find a link to a technical paper on the subject:
the copy will introduce the next chroma-delaying per one line, resulting in a additional shift of two lines per frame
Obviously there are additional chroma problems inherent in the VHS specification. This is especially true of NTSC (the OP's tape is PAL) because of how the color carrier is multiplexed into the existing B&W signal ("existing" referring to the TV signal prior to the first national color broadcast on January 1, 1954). However, that color bleed, while related, is a separate issue from what happens when a copy is made of a VHS tape using another VHS recorder.
Sorry but Im not the right guy to write such a guide, also I dont have nor the time nor the mood in this moment to write it.
However here are what you probably suspect you have to do
1- Learn avisynth basics
2- Try small and simple scripts
3- Learn by example . Explore scripts already made by others try to adjust them to fit your needs .Play around with filters and their settings.
4- Identify the major problems / artifacts in your captured files that you need to address
5- Determine what filters are needed, and at what strength.
6- Make your first full scripts
7- Optimize your scripts. Adjust by trial and error filters, positioning and settings to get the best results
Here are several links with a lot to explore you can get many others searching for vhs restoration avisynth guides or similar text. Dont forget that most of them are very outdated so have that in mind , even so they can help you to understand how to use and learn avisynth.
It will depend on your previous background and free time available for learning avisynth but quite soon you will be writing satisfactory scripts.
Scintilla's Guide to AVISynth Postprocessing
Use Google translator for German parts
A/v artifacts atlas
Last edited by FLP437; 1st Feb 2020 at 11:42.