Log in

View Full Version : My PAL S-VHS clean up script


2Bdecided
28th March 2008, 15:16
This isn't magic, and the best parts/ideas were taken from other people, but I'm sharing it in case it's any use to someone...

avisource("whatever.avi")

# PAL = TopFieldFirst
assumetff()

# Make progressive
Bob(0.0,1.0) # better bobbers are available ;)

# Fix (S-)VHS chroma shift
Vshift=2 # determine experimentally
Hshift=2 # 2 lines per bobbed-field per tape generation (PAL); original=2; copy=4 etc
mergechroma(last.crop(Hshift,Vshift,0,0).addborders(0,0,Hshift,Vshift))

# Need YV12 for mc_spuds and aWarpSharp
# (Consider doubling vertical resolution to prevent loss here if you really care?)
# ( - I don't, so I haven't tried it)
converttoyv12(interlaced=false)

# Store the noisy version
a=last

# Denoise with mc_spuds
mc_spuds(chro=true)

# warp horrible fuzzy chroma to match nice sharp luma
c=aWarpSharp(depth=20.0, thresh=0.75, blurlevel=2, cm=1)

# put a little of the original noise back in to avoid "plastic" look
overlay(a,opacity=0.4) # 0.5 keeps 50% noise, 0.25 keeps 25% noise etc

# completely replace chroma with nice version
mergechroma(c)

# go back to a nicer colour space before re-interlacing
# (not worth it for DVD etc, but good if you want to store lossless YUV and maybe take frame grabs)
converttoyuy2(interlaced=false)

#re-interlace
assumetff()
separatefields()
selectevery(4,0,3)
weave()

If anyone spots any bugs, please let me know.

Note: I'm using the original version of mc_spuds. Other versions (and other sources) might benefit from different options, and more or less noise mixed back in.

Note: I'm intentionally not blanking the head switching at the bottom since it usually includes good picture on my tapes, and I'm hoping to inpaint the bad line or two one day! If you prefer to paste a black border over the bottom to hide the mess, use...
crop(0,0,0,-16).AddBorders(0,0,0,16)...at the end.

Comments welcome.

Cheers,
David.

scharfis_brain
28th March 2008, 16:15
if you got the processing power I suggest to use nnedi(field=-2) instead of bob().

You'll get much better denoising at straight diagonals

g-force
28th March 2008, 16:19
I think the chroma shift part is pretty clever. Nice work!

suggestion: instead of "crop(0,0,0,-16).AddBorders(0,0,0,16)" you could use "Letterbox(last,0,16)" since you're croping and adding borders by the same amount.
-G

2Bdecided
28th March 2008, 17:34
g-force,
I didn't know about letterbox - thank you g-force. I'm currently keeping the overscan in the hope of improving it one day, and intend to just crop it out completely for PC applications (mainly facebook/youtube) - but if I decide to mask out the DVD res version I will use letterbox.

scharfis_brain,
The denoising is already painfully slow - I'll see how much worse nnedi makes it. I started with bob(), but found bob(0.0,1.0) was much sharper (preserved the original lines, of course). I also tried mcbob (experiment only - way too slow for actual use) and it sometimes improved sharpness a little more, but occasionally got confused by the noise and added artefacts. I'll see if nnedi has the same issues.

Thanks for the feedback.

Cheers,
David.

fjhdavid
26th February 2009, 18:23
Dear 2Bdecided,

I finally discovered your script which works very very good for me. I use fft3dGPU instead of MC-Spuds for "best quality/speed" ratio.

But I wanted to know if you improved your script since march 2008?

and how did you find the settings for awarpsharp (as your settings value are different from what MarcFD specifed)?

Thanks
Francois

2Bdecided
26th February 2009, 20:15
I haven't changed it, though I'm not convinced by my use of awarpsharp. I chose those settings after testing with some critical scenes (i.e. ones where there were some narrow areas of colour which would disappear if it went wrong) but having used it on more content now, I've seen some images where it replaces a "vague" colour or join of colours with the wrong colour. Didee originally proposed applying it to a sharpened luma image to have more edges to warp to, but that made the problem worse for me. YMMV!

Cheers,
David.

fjhdavid
26th February 2009, 21:33
I tested it with DVE essential.
I played the DVD "DVE essential" and recorded it on a DVD recorder with analog wire.
Then I use photoshop to check and magnify pictures.

and I can say that your script produce really good results! I can't send you pictures (they are too big) but DVE essential has special patterns with a lot of colors transitions and your script reduces them by, at least, 70% of the bleeding, and it smooths the colors transitions.

For the wrong colors you talked about, are they exeptional (I think "the wrong" comes from "the sum of two or three colors" from special transition or intersection) but they are not wrong...

oh yes, I forgot, what do you think about MC_spuds filter (except the fact it is really slow)?

(I tested it yesterday for a long time, tweaking parameters, and I am not impressed compare to fft3d filter. In fact fft3dfilter looks more robust and "linear" as sigma increased. If you leave sigma around 1.5-2 for Y and 3 for U,V as Fizick said in the documentation, you have pretty good result yet)

fjhdavid
1st March 2009, 23:52
Dear B2decided,

With some film (recorded with my dvd recorder) during fast horizontal motion (horizontal panoramic), I can see a green halo at the back of the object which is moving, especially when the object is black and move in front of a white background.

Why the halo is green and not black?

what would you suggest to remove this green halo?

thanks

2Bdecided
2nd March 2009, 11:28
Hi fjhdavid,

It's not "my script" that's clever - it's mc_spuds (which itself is using lots of powerful functions) and awarpsharp (as suggested by Didee) that's clever. I'll try fft3dfilter one day.

I don't have any suggestions for the problem you describe. Maybe you could start a new thread, post a small sample, and someone might have an idea.

Cheers,
David.

fjhdavid
16th March 2009, 23:54
just want to know David:

in your script, is the luma left unchanged (if you exclude the denoiser)?
or is the luma a little bit modified through the awarsharp function?

thanks
Francois

2Bdecided
17th March 2009, 11:54
Hi,

I believe the only luma processing is the denoise. So without the denoise, the luma is unchanged.

You can check that everything is working as it should:

Add the line "b=last" after the line "assumetff()", and then add the line "subtract(last,b)" right at the end of the script. Drop this into virtual dub, and it'll show you the difference between the input and the output. If you add greyscale() at the end of the modified script, it'll show you the luma difference only, which (if you comment the denoiser out) should be nothing (pure grey = nothing).

Cheers,
David.

fjhdavid
1st April 2009, 14:50
Yes, I can confirm, you get pure grey: mean=127, deviation=0.

It means that the luma is unchanged (except denoising of course).

Thanks, I will use this script as it can't hurt luma!

yup
1st April 2009, 17:32
2Bdecided!
Please explain Fix (S-)VHS chroma shift
Vshift=2 # determine experimentally
Hshift=2 # 2 lines per bobbed-field per tape generation (PAL); original=2; copy=4 etc
Especialy Vshift.
yup.

2Bdecided
1st April 2009, 20:10
The labels on those two lines are swapped. It should be

Fix (S-)VHS chroma shift
Vshift=2 # 2 lines per bobbed-field per tape generation (PAL); original=2; copy=4 etc
Hshift=2 # determine experimentally

Vshift: The chroma in PAL VHS drops by one line per field (2 lines per frame) per generation of tape.
Hshift: The chroma on these tapes seems to be shifted by a couple of pixels. This shifts it back.

Cheers,
David.

Maximus_G
3rd April 2009, 00:33
This isn't magic, and the best parts/ideas were taken from other people, but I'm sharing it in case it's any use to someone...

That's a great idea to put it all in one place. Thank you! I've been just looking for such a script and gonna try it right now :)
And thank you guys for the good comments!

fjhdavid
3rd April 2009, 21:27
just some additionals infos about how you can use this script:

you can also use it with "analog" recording on DVD. In this case you usually don't need the "shift part" of the script, at least for me, there is no color shift.
2bdecided, is vshift only VHS related?

I also changed the thresh to 0.5 (instead of 0.75) as Marc FD suggest this is the best setting for awarpsharp but maybe 2bdecided could add more about this choice?

and I removed the "original noise back" as I don't have "plastic" look. The plastic look may also come from the "S-VHS resolution lost?" or the denoiser you apply.

But I least for me, results are very good (I suggest you test it on a DVD test with color bar pattern and you will be surprised, even if the script effect is more difficult to see with "real movies")

but don't forget to tell us your results please!!!

PS: 2bdecided, you didn't use the BorderMirror function of Didee as you don't have the color artefacts that aWarpSharp was producing on the outmost frame borders?

2Bdecided
4th April 2009, 20:29
fjhdavid, I can remember seeing the border artefacts, but don't have them any more. The less aggressive aWarpsharp settings don't produce them (as much / at all). I may have used mirror borders if they were still there - if I wasn't feeling very lazy. I might have done a crop+add borders at the end instead - mostly the artefacts only creep into the already black borders.

I chose those settings by playing with a clip with strong colour transitions and obvious colour bleed, tweaking them until it looked right - i.e. colours stopped where they should. The chroma resolution of (S-)VHS is terrible, and diagonal corners of triangles (for example) never get the right colour whatever you do!

Cheers,
David.

fjhdavid
5th April 2009, 13:50
In fact you mean that your settings are not "sufficiently" aggressive so you don't see the border artefacts?

(I say that, because after 20 films with your settings I am not able to see them...) but I can also see diagonal corners of triangles problem depending of colors combinations; I can only see them from green to magenta transitions with color bar patterns....