Log in

View Full Version : Noisy VHS workflow. AVS+MVBOB+MVDenoise+Seesaw+H264 = sigh!


koopa
23rd August 2008, 18:56
Hey everyone, thanks for looking. (and to those at videohelp.com)

I restore VHS tapes. Or at least I'm trying to... and I'm trying to get everything into an AVS workflow (the idea being that even if it takes my computer the rest of my natural life for HQ renders, at least I can go do something else while the scripts automatically handle everything).

My setup is this:
- Canopus ADVC-300 (2D & 3D NR off, edge enhancement off, Auto-gain, sharpening max, contrast/chroma/lum set to keep within 0->255 limits with a graph for each tape)
- Panasonic nv-fs200 (ag-1980) (connected via SVIDEO, set to edit, TBC on (normally), don't know how to service (tips?), auto-tracking, always processing PAL tapes).
- Core II Duo, 1.6TB, Firewire (Microsoft codec, how DO you switch to Canopus/FFDShow, what are the benefits?)

My old workflow was this:
- Record to DV AVI (type 2) with a program that lets me see output waveform (then I set the sliders on the canopus to get a good looking image / within graph borders of 0->255)
- Process with TMPGenc Xpress 4 (Deinterlace -> double framerate (weighted int.), then colour correction (have 1920x1080 colour calibrated panel), noise reduction (temporal 50 to 75%), colour phase correction, contour (sharpening), volume adjustment).
- Output to WMV (or interlaced DVD upon request).

Now recently, I have been frustrated by the poor quality of WMV (loss of detail, macroblocking), sometimes barely superior to MPEG2 (3 hour tapes to DVD-DL), and being fond of MeGUI for encoding non-restoration jobs, I looked to h264+AAC@MP4 as a new container (advantages being, much higher compression quality, playable on iPhone (at correct level)). Searching these forums + doom9 + AVSforums has been a real eye opener, there have been so many advancements since I last updated my workflow (mainly in the area of MVTools and motion compensation).

So, help me, please! I have been searching for days, forsaking sleep and sanity, and am having trouble putting a script together with variables I can understand (not just cut and paste, the next video might need different parameters). I want to eliminate TMPGenc from my workflow (because it can not frameserve, HUFFYYUV/Cineform intermediary is too slow and its own MP4 engine is worse than its WMV output).

I have tried lots of MVDenoise (1/2/3) scripts, have had some luck, but the speed is unacceptable (I consider 2-3fps or greater on a Core2Duo 2.2Ghz acceptable). I can not find a plugin/program that allows me to change colour and colour phase while viewing the results (and calibrating by eye). But I DO love MVBob (seemingly far superior and faster to MCBob, has a natural denoising quality, with very little detail loss. I can't get MCBob to ever look much better than YADIFMOD+NNEDI).

This is my current script:

source=DirectShowSource("c:\DefinitelyDonkeyPorn.avi", audio=false)
Import("C:\Program Files\AviSynth 2.5\plugins\MVBob\mvbob.avs")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_MaskTools.dll")
frames=source.MVBob()
backward_vec1 = frames.MVAnalyse(isb = true, lambda = 1000, delta = 1)
forward_vec1 = frames.MVAnalyse(isb = false, lambda = 1000, delta = 1)
frames.MVDenoise(backward_vec1,forward_vec1,tht=10,thSAD=300)

It gets me a respectable 3 fps, no colour correction, no phase correction, lets forget about audio for a minute (and how I wish that 2-pass encodes would automatically go faster by skipping some filters for the first pass!)

I do not know how to enhance or reduce its noise correction, it just is what it is atm. (played around with tht and thSAD, no change). I'm also interested in slight sharpening (looked up seesaw, but it seemed to only enhance the noise in its simple mode, and in its complex mode it did nothing at all).

I tried this script:
MVBob()
ConvertToYV12()
mc_spuds(2, 2)

VERY slow, but no better than the above script, and at (2, 4) it was seriously removing some detail!

backward_vec2 = frames.MVAnalyse(blksize = 8, isb = true, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
backward_vec1 = frames.MVAnalyse(blksize = 8, isb = true, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec1 = frames.MVAnalyse(blksize = 8, isb = false, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec2 = frames.MVAnalyse(blksize = 8, isb = false, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
frames.MVDeGrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=40000,idx=1)

EXACT same as top script, but half speed...

So please people, any help you could lend in any area would be great. MC_Spuds seemed so promising, but at all times it was slower or smearier than my current script. Perhaps I am using it wrongly (happy to upload some examples). I'm not being paid for any of this work btw, it is for friends and family who are slowly destroying their VHS collections in cheap machines...

Thanks! :)

jeffy
23rd August 2008, 21:23
frames.MVDeGrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=40000,idx=1)



Isnt't this too much?

Sagekilla
23rd August 2008, 22:38
Try using MVDegrain1/2/3 solely as your denoiser. Use 1, 2, or 3 according to how much noise needs to be removed. May I also recommend TempGaussMC? It's here: http://home.arcor.de/dhanselmann/_stuff/

I've heard that it tends to be very sharp and clean looking, since it does deinterlacing, denoising, and sharpening as part of it's function. It's fairly slow, but it may be what you're looking for.

koopa
24th August 2008, 17:03
Wow, with TempGaussMC, it has jumped another level in the quality of the Bob (visibly better in every frame), and there just feels like there is more apparent resolution. However, its denoising functions seem to have left some low frequency noise (colour "blotches"). I've tried fiddling with the parameters (and going up to 1/2/3 on TR2 doesn't affect the LFN).

I can add Hqdn3d(4) back in to reduce the noise, but that kills details and CPU cycles.

Thanks for the advice with the old script, put thSAD back to 300, don't know how that happened!

So, any tips for a low CPU usage external low-frequency noise filter (source.BlotchesBeGone(LeaveAllFineDetailsPlease, 0.1CPU)), or better yet, a parameter I've missed within TempGaussMC, or a way to get TempGaussMC to do BOB-only?

Thanks!

Sagekilla
24th August 2008, 17:06
I don't personally know the settings of TempGaussMC, but my best suggestion would be to play around with the settings and learn :) Otherwise, you can try running FFT3DGPU (if you have a good GPU) and utilizing the various sigmas at different strengths. sigma = high frequencies, sigma2 is lower, 3 is even lower, and 4 is lowest. So I believe you can try setting sigma=0,sigma2=0,sigma3=0,sigma4=1 and work from there to see if that helps any.

koopa
28th August 2008, 06:45
Alright, I have cut out the low frequency noise with fft3dfilter in a script pinched from Didée:

DirectShowSource("C:\DefinatelyDonkeyPorn.avi", audio=false)
Import("C:\Program Files\AviSynth 2.5\plugins\TempGaussMC_beta1.avs")
setmemorymax(768)
TempGaussMC_beta1()
source = last
backward_vec2 = source.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
backward_vec1 = source.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec1 = source.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
forward_vec2 = source.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=2, idx = 1, truemotion=true)
smooth = fft3dfilter(bt=3, sigma=4, plane=0)
smooth.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=1)

The quality is great, deinterlace is almost perfect, the denoising retains so much of the details. The only problem is that the script runs at 1.1fps (per core, so I'm splitting the file into two). Is there anything I can do to MT the script, or speed it up in any way for the equivalent processing? Thanks very much guys!

2Bdecided
28th August 2008, 09:34
1.1fps is fast for a Didée script ;)

TempGaussMC_beta2() uses MT version of something, IIRC. It's in a thread very close by - try search.

Cheers,
David.

Didée
28th August 2008, 10:48
1.1fps is fast for a Didée script ;)
Thank you very much. :p


TempGaussMC_beta2() uses MT version of something, IIRC. It's in a thread very close by - try search.
Yes, definetly try that, but ...


... you've also to think about "temporal complexity" of a script -- and this script here creates HUGE temporal complexity.

TempGaussMC internally is already doing sort of MVDegrain( MVDegrain(source)) meaning that for each input frame of the outer MVDegrain() the full circle of the inner MVDegrain has to be done several times.

Now, with MV-denoising performed on the result of TempGaussMC, you're creating a chain like

MVDegrain( MVDegrain( MVDegrain(source))).

The ressource usage of such a script is extraordinary. Call yourself lucky that this script does run at all (it probably wouldn't on my ancient low-spec PC).

Think about bifurcation in the fractal domain - it starts harmless, but already after very few iterations, it converges to infinity ...


If you have a script with a filter chain that uses ressources in the range of gigabytes, then your milage with multi-threading will be rather small, or the script won't even run at all (because of the usual 2GB process limit on 32bit Windows).


BTW, MVTools really is a ressource hog. I've a script here - and it's not even overly fancy - that uses ~350MB physical memory, but ~1GB of virtual memory ... on a cropped 416*576 clip!! Processing full PAL is borderline, processing 720p is not possible, not at all.

Looks to me like MVTools' way of using memory & ressources is, erh, not fully optimised...

koopa
28th August 2008, 15:00
OMG, Didée commented on MY thread *small celebrity crush* :p

Yes browsing through TempGaussMC pretending I understand it (I try to pretend its badly written Java), I can see the recursiveness of the script's relationship to its memory.

That being said, I'm on 2Gb Mem on a 2.16GHzCoreIIDuo, 400Mb taken by OS, and I'm running TWO of those scripts (to use both cores, split the file in half at a 6+ black frame break), and they each only use 375Mb of memory exactly each (plus 445Mb of Swap File), so no probs there.

I just can't help but think, that with all the different occurrences of MVDegrain that occur, there are surely variables that are being re-calculated for no reason (like not having the right idx value set, if I've understood right). Is there any way for me to initialise TempGaussMC in a way that shares its motion analysis with the MVDegrain I do later, or to include THAT MVDegrain2 process within the TempGaussMC script.

My best attempt has been to replace it all with:
TempGaussMC_beta1(source, 2, 2, 2, 4, 0, 4, "EEDI2", 8, 8)
fft3dfilter(bt=3, sigma=4, plane=0)

To up the level of MVDegrain-ing within TGMC to level 2 (or even level 3), which resulted in the final output (now minus the external MVDegrain2) having a few more errors of interpretation (scrolling text across motion scene leaves artifacts, has a few problems with two motion scenes at 50% transparency each) and overall greater bluriness (even with sharpness turned up to 8)!

How I wish I understood just a bit more of scripting, how memory spaces are handled and referred, because I've got a feeling that there is a lot of wasted cycles going to recalculation (ducks while people who actually know what the hell they're talking about reply, and thank you very much for your excellent scripts so far!! 1.1fps (x2) of pure bliss is better than 25fps VCR->DVD (MPEG2, CBR blocky blehness) machines)!

Mystery Keeper
28th August 2008, 15:09
Denoising should be applied BEFORE deinterlacing.

separatefields()
a=selecteven().<your denoiser here>
b=selectodd().<your denoiser here>
interleave(a,b)
weave()

Adub
28th August 2008, 16:59
Wait, to you mean before INTERLACING? Because there is nothing wrong with denoising after DEinterlacing.

Mystery Keeper
28th August 2008, 17:11
Denoising beforehand makes deinterlacing more accurate, doesn't it?

2Bdecided
29th August 2008, 13:49
Denoising beforehand makes deinterlacing more accurate, doesn't it?But in your example you are "deinterlacing" by separating fields. So you're giving the denoiser a really badly "deinterlaced" source which is much harder to denoise properly than a source processed through a good deinterlacer.

mcbob is quite sensitive to noise.
tgmc works quite well with it.

I always deinterlace and then denoise. If I'm re-interlacing later, I don't worry too much about the deinterlacer, merely to save time. tgmc is visibly better than bob even then, but life is too short / my PC is too slow!

Cheers,
David.

Mystery Keeper
29th August 2008, 15:00
But in your example you are "deinterlacing" by separating fields. So you're giving the denoiser a really badly "deinterlaced" source which is much harder to denoise properly than a source processed through a good deinterlacer.

That's a classical trick which you completely misunderstood. It doesn't deinterlace. It makes denoiser process each field separately and then puts them back together. Techincally denoiser processes two perfectly progressive clips.

2Bdecided
29th August 2008, 15:59
Yes, sorry, I missed the two denoise parts - but I've run that exact script myself.

Those two clips are anything but "perfect" - they each have exactly half the spatial resolution of the source and the output and lots of aliasing - each individual denoiser can never see the other half of the spatial resolution.

That may be the least bad approach for certain circumstances, but there's no use pretending its perfect. My S-VHS sources work far better with bob, denoise, re-interlace.

Cheers,
David.

Yoshiyuki Blade
29th August 2008, 17:53
I generally like to use edimode="nnedi" for tempgaussmc. The last time I used EEDI2, it was more prone to creating an "oilpainting" look, so I avoided using it.

EDIT: Here's a good post to read about it: http://forum.doom9.org/showthread.php?p=1154607#post1154607

koopa
30th August 2008, 15:14
Thanks Yoshiyuki, NNEDI is superior in almost all cases (on my videos) to EEDI2, though I'm afraid again the tradeoff has been memory and speed... but quality shall prevail! :) It's the darndest thing, I've kept "quality" samples of each of my methods that I've been developing over the past months, and things that I considered "almost perfect" two weeks ago, are now just mediocre! But it doesn't feel like the quality is getting better, it feels like my "samples" are aging badly, hehe, which means that perhaps my best master today might be rubbish in 10 years time (buys comic-guy-esque mylar pouch to preserve precious VHS tapes!).

A new infuriating aggravation is colour processing... greens and reds need to be turned down (blue up), gamma could afford to be brought up a few notches, chroma channels need to be shifted to the right (and shrunk?). I used to use TMPGenc for all this work, but now all I can see when I use TMPGenc (and the histogram function) is banding. I actually have no way to adjust contrast curves without banding, I have to get it right from the VCR capture (ie: capture sample, histogram() it, capture again, histogram() it, etc). Is there any way to do it without seeing those characteristic bands (you can actually see the banding in the histogram graph from the advice on this page!! http://www.doom9.org/index.html?/capture/postprocessing_avisynth.html Maybe that's ok for non-Didee denoised awesomeness, but it's REAL obvious now!).

Anybody got any suggestions for processing these things without banding (before I jump on the 10bit for Avisynth bandwagon)?

And as always, thanks heaps guys! :)

2Bdecided
30th August 2008, 18:57
That's really easy - do the adjustments before denoising. The noise acts as dither: no banding.

(The subsequent denoising introduces no more or less banding than it would have done anyway - unless it's so mild as to be a NOP).

Cheers,
David.