Log in

View Full Version : yet another thread about denoising old VHS tapes


brett
1st October 2004, 22:03
I've got an 11-year-old tape (looks like a 3rd-generation dub) of my late father-in-law's trip to the Yukon. He just died last week, so now a lot of people really want copies of this tape (it's the only video of him). This is something that I'm trying to get right, since it's not for me -- it's not something I'll really be able to redo. I just want to make DVD's for about 10 people from it.

So, I took the VHS tape to a friend of mine and we copied it from VHS onto MiniDV with a nice JVC SVHS deck and a SVHS line-in on a good Sony DV cam, and now I've got the DV file on my hard drive. I think this is about the best possible capture I could have of this old tape.

Now I'm playing around with filters. I really don't need to over-filter, because it's only a 75-minute tape, so I'll be able to encode it in CCE with an average bitrate of almost 7000kbps. That said, the camera operator was very shaky, and we're talking about a VHS camcorder from the early 90's (this was filmed in August '93).

If people think they may have any brilliant insight, I'll post some caps if it'll help. This is the script I'm currently working with, but it's not working right.

This is from a DV source, and I'm going to drop the .AVS file right into CCE. Input is 720x480 interlaced NTSC DV, output is 704x480 interlaced MPEG2 with 32px black bars on top and bottom (I think it's worth it to keep from encoding all the noise on the top/bottom).


LoadPlugin("C:\DVD\LoadPluginEx2.dll")
LoadPlugin("C:\DVD\dustv5.dll")
DirectShowSource("jim-yukon-DV.avi")
Crop(2,30,-14,-34).ChromaShift(L=-6).Tweak(0.0,0.8,0.0,1.0)
f=SelectEven(SeparateFields()).PixieDust(limit=5)
ff=SelectOdd(SeparateFields()).PixieDust(limit=5)
Interleave(f,ff).Weave().AddBorders(0,32,0,32)


When I use Convolution3D, the script works fine, but now that I switched to PixieDust, one of the fields has turned black.

I know there are many threads about VHS capture, but most of them are talking about deinterlacing. I will be encoding to interlaced MPEG2.

Any comments are appreciated. I'll be gone for two days, but I will definitely be checking back.

Thanks!

scharfis_brain
1st October 2004, 22:13
my way restoring old VHS tapes.

1) load avi in an avs.
1a) add reinterpolate411()
2) bob-deinterlace it to 59.94 fps.
either with tmcbob() or with tdeint(mode=1)
(ELA [edge directed interpolation] is the important thing here)
3)apply a chroma-shift, to shift back the colors to their correctspatial position
4) open this script in VDub.
5) add deshaker
6) run the first pass (don't use RGB, use greyscale!)
AR: NTSC
Frame type: progressive
7) run the 2nd pass
8) save it as HuffYUV.

9) load this deshaked HuffYUV to a 2nd AVISynth-Script.
10) apply a temporal denoiser
10a) preferrable using the function depaninterleave of depan.dll from fizick
11) do further corrections
(saturation, brightness, contrast, hue, sharpness)
12) reinterlace this.

if you have further questions to each step, just ask.

Video Dude
1st October 2004, 22:16
Originally posted by brett
When I use Convolution3D, the script works fine, but now that I switched to PixieDust, one of the fields has turned black.
The reason one field turn black is because PixieDust can be called only once in a script (unlike most other filters). You have it called twice in your script.


If you want to use PixieDust and leave it interlace, you can use viewfields/unviewfields instead of SeparateFields/SelectOdd/SelectEven.

For example:

LoadPlugin("C:\DVD\LoadPluginEx2.dll")
LoadPlugin("C:\DVD\dustv5.dll")
DirectShowSource("jim-yukon-DV.avi")
Crop(2,30,-14,-34).ChromaShift(L=-6).Tweak(0.0,0.8,0.0,1.0)
ViewFields()
PixieDust(limit=5)
UnViewFields()
AddBorders(0,32,0,32)

Si
2nd October 2004, 00:17
For the other people reading this thread...

ChromaShift, ViewFields and Unviewfields are plugin filters and need LoadPlugin statements as well :)

regards

Simon

brett
8th October 2004, 20:49
Video Dude:

Thanks! I never would've figured that out. I ended up using exactly that script (except I turned it down to Tweak the gamma 0.85 and PixieDust limit=3) and it worked great, so that's probably what I'll stick with.


scharfis_brain:

I really don't want to over-filter here, since I'm making a DVD with a really high bitrate (probably going to do a 3-pass encode in CCE with min=3000kbps, max=9000kbps, avg around 6000-7000kbps).

I'd still like to know about this script of yours, though. Why are you using a bob deinterlace? With interlaced NTSC DV, won't that script of yours deinterlace then reinterlace the video and totally screw it up (or at least add some ghosting)? Why do do a pass in greyscale? Are you talking about converting old VHS movies (that were originally film) or something?

Deshaker is a VDUB filter, so I can't see it being worth converting to RGB and back, but if it's something that would work wonders with old camcorder VHS tapes, that might be worth it. Are there any good AviSynth filters that could give it some image stabilization?

brett
8th October 2004, 20:52
Does anybody know where I can get DePan to try that out? It's not in the AviSynth Filter Collection, and the lick Fizick said it was at (http://bag.hotmail.ru) doesn't work.

edit: nevermind... the link is working fine now (before it was saying "connection refused".

EpheMeroN
8th October 2004, 21:19
I'm gonna be doing VHS restoration soon and I read in this thread that you're using ChromaShift() in the script.

How do you correctly calculate the numbers for ChromaShift? I'd like to know this for future reference.

Piper
8th October 2004, 21:26
@brett: Just a suggestion from my own experiences with dealing with "one of" sources like this. You may want to keep handy at least one copy of something as close to the original source as possible. I don't know if you still have the miniDV tape, but if you don't - you may want to burn an unfiltered copy of your source to dvd. That is, don't deinterlace, filter it in any way. From the sounds of it, you have more than adequate bitrate to handle an even noisy source like this.

A dvd backup won't be ideal for future editing, but it'd be something. You never know when that "uber dust" filter will come along and make your previous efforts look bad. I'm not saying this will necessarily happen in your case, I can only speak from my own experiences.

brett
8th October 2004, 23:00
Originally posted by EpheMeroN
I'm gonna be doing VHS restoration soon and I read in this thread that you're using ChromaShift() in the script.

How do you correctly calculate the numbers for ChromaShift? I'd like to know this for future reference.

It's definitely a trial-and-error thing. You ahve to find a scene with bright colors and a lot of contrast and try to make it match up a little better.

Generally speaking, I think the Chroma shifts 2 pixels down every time you record a tape... So the original would need ChromaShift(L=-2), the first dub would need ChromaShift(L=-4), etc. I think some VCR's might induce 4 pixels of shift each time. No matter what, it's something you have to check to make sure. On an old tape, the colors will usually bleed a little anyway so you're really just estimating.

scharfis_brain
8th October 2004, 23:10
@brett:
I am talking about Camcorder Video Footage. Not FILM.

1) bob-deinterlacing is needed for best quality deshaking and denoising.
It is mainly used, to align the fields spatially and to get less jaggy diagonals when doing the deshaking.
(deshaking is a matter of taste, but IMO it is very useful for compression, denoising and viewing)

after the bob-deinterlacing, the chromashift gets applied (better influence on vertical shift, cause the fields are now doubled in height)
then, the deshaking is done.
the greyscale-part only applies to the movement-analysis (1st pass).
It speeds up the 1st pass and gives more stability, cause VHS-colors are very instable and blurry.
the 2nd pass is done in full color, then.
and the RGB-Colorspace doesn't matter here for VHS, cause of its poor horizontal and vertical chroma-resolution.

after deshaking, one can apply a denoiser, that should be motion-compensated, too.

after all this filtering, the reinterlacing restores an interlaced stream, that has a BETTER image definition and clarity, as if the video had been processed fieldseparated.

that's just my experience.

but the process of doing it this way is very hard, time & HDD-space-consuming, and also very error-prone (human-error, of course :) )

North2Polaris
15th October 2004, 03:12
Originally posted by scharfis_brain
my way restoring old VHS tapes.

9) load this deshaked HuffYUV to a 2nd AVISynth-Script.
10) apply a temporal denoiser
10a) preferrable using the function depaninterleave of depan.dll from fizick
11) do further corrections
(saturation, brightness, contrast, hue, sharpness)
12) reinterlace this.

if you have further questions to each step, just ask.

@scharfis_brain,

I enjoyed giving your method a try on an old camcorder VHS tape! From the depan help file, I put together the following for the second script:

AVISource("D:\deshaked.avi")
i=converttoYV12()
mdata=DePanEstimate(i)
DePanInterleave(i,data=mdata)
FluxSmoothT()
selectevery(3,1)


Is this what you had in mind?

At the end of this I have a 59.94 fps YV12 file.

What's your next step and the target format? Your step 12 is to reinterlace this.

Thanks.

North

joshbm
15th October 2004, 04:08
Wow, good post. I too would like to restore old VHS tapes.

@scharfis_brain:
Could you post maybe an example of both your avs scripts. I'm quite curious to what they look like.

Regards,
joshbm

scharfis_brain
15th October 2004, 14:24
the deinterlacing function: stupid tomsmocomp-upscale for better edge definition

function Tomsstupidbob(clip c)
{ input=c.separatefields.tomsmocomp(1,-1,0)
a = getparity(input) ? input.selectodd : input.selecteven
b = getparity(input) ? input.selecteven : input.selectodd
a=stackvertical(a.crop(0,0,0,1-a.height),a.crop(0,0,0,-1))
output = getparity(input) ? interleave(b,a) : interleave(a,b)
output.assumeframebased
}

1) script, to feed deshakers 1st pass (analysis):


avisource("vhs-cap.avi") #I am assuming 704x576 or 720x576 here.
assumetff() # for TV-Card caps
#assumebff() for DV-Device-caps
bob()

open this in vdub. add deshaker, and set analysis to greyscale. and set AR to 1.094 and video type to prgressive.

2) script, to feed deshakers 2nd pass (deshaking):

avisource("vhs-cap.avi") #I am assuming 704x576 or 720x576 here.
assumetff() # for TV-Card caps
#assumebff() for DV-Device-caps
Tomsstupidbob()
#converttoyuy2() #if not YUY2
shift=2 # apply the chromashift here.
last.mergechroma(last.crop(0,shift,0,0).addborders(0,0,0,shift))
converttorgb24()
crop(a,b,-c,-d) # crop away ALL garbage do not bother about non mod 4 sizes
()

open this script in vdub, add deshaker, load the previously created log-file.
in 2nd-pass apply:
frame size: 720x576, AR 1.094 , no extra zoom, no edge compensation, 25 prev & 25 future frames.
set the other deshaking thresholds to your needs.
run deshaker & save that file

3) postprocessing the deshaked video.


avisource("deshaked-vhs.avi")
i=converttoYV12()
mdata=DePanEstimate(i)
radius=2
DePanInterleave(i,data=mdata,prev=radius,next=radius,mirror=15)
FluxSmoothT() # or any other denoiser you like to use
selectevery(radius*2+1,radius)
#limitedsharpen() #maybe.....
converttoyuy2() #or rgb24() but it is important, to it BEFORE the reinterlacing.
#now: reinterlacing:
#assumebff() # for BFF-Output
assumetff() # for TFF-Output
separatefields().selectevery(4,0,3).weave()

North2Polaris
17th October 2004, 05:43
@scharfis_brain,

Thanks for posting your scripts!

Would you make any changes if you were using 704x480 or 720x480, other than different settings in deshaker?

North

scharfis_brain
17th October 2004, 09:19
set the ARs to Standard NTSC for analysis and 2nd pass.
(IMO your question was self-answering....)

North2Polaris
17th October 2004, 14:26
Originally posted by scharfis_brain
set the ARs to Standard NTSC for analysis and 2nd pass.
(IMO your question was self-answering....)
@scharfis_brain,

Just making sure. Fortunately, after a couple of years of using AviSynth, I can "read" scripts that are more complicated than I can write myself. ;)

In your script, are the following lines the same as using the "ChromaShift.dll" plugin?

shift=2 # apply the chromashift here.
last.mergechroma(last.crop(0,shift,0,0).addborders(0,0,0,shift))

Thanks.

North

scharfis_brain
17th October 2004, 14:32
jep. they are.
I don't know, what is faster, but I am to lazy to load more plugins than needed.

EDIT: I edited the script-comment of one of my posts above...

joshbm
18th October 2004, 00:35
I was looking at your script and was wondering... why 2 motion stablizers? You've used DeShaker and now you use DePan, why? Was it your intention to use the "inputlog" tag and use the log from DeShaker with DePan?

PS- Would you recommend a DeShaker on source that originated on DV as well? Or strictly VHS?

Regards,
Josh

scharfis_brain
18th October 2004, 05:50
DV as well. you can use any source you want to.

I used two motion stabilizers, cause the first one is used for the stabilizion itself and the 2ndone is used for assisting strong temporal noise reduction.

we know, that camcorder footage has lots of pans (after deshaking, thes pans are equalized or flattened), so a global motion compensation (this is what depan does) will greatly improve the quality of denoising.

brett
29th October 2004, 04:58
Well, I ended up using Deshaker, which is wonderful, but I just couldn't bring myself to deinterlace my video like that script does. Deinterlacing/reinterlacing loses temporal information, no matter how you do it, and the temporal component is about the only non-blurry aspect of a VHS tape, so I don't see how it could be worth it.

I tried to use DePan, but it was a pain in the ass and didn't look like it would work as well as Deshaker, so I figured I'd be better off just converting to RGB and using VDub.

The steps I used were:

VHS tape played from a nice JVC SVHS deck and captured with a Sony DV cam. End up with a 16GB (74 min) DV file.

Pass 1 = Deshaker log file pass
pass1.avs loads DV file and just applies the ChromaShift, the AVS is loaded in VDub and Deshaker Pass 1 filter is used
Deshaker options = default, except using NTSC pixel aspect, Interlaced LFF video (for DV), Full Scale, Greyscale

Pass 2 = Deshaker pass
pass2.avs loads original DV file, adds 30 frames to the end of the clip (for Deshaker lag) with UnAlignedSplice, applies ChromaShift, then ConvertToRGB
pass2.avs is loaded in VDub and Deshaker Pass 2 filter is used
Deshaker options = default, except using NTSC pixel aspect, no edge compensation, using prev/future frames (30 frames)
file is saved in VDub to a 52MB HuffyUV (in RGB)

Pass 3 = filtering pass
pass3.avs loads 52MB stabilized HuffyUV file, Tweak(0.0,0.85,0.0,1.0), PixieDust(limit=5). Dust seemed to add another 1 frame lag, so the actual script is:

LoadPlugin("C:\DVD\LoadPluginEx2.dll")
LoadPlugin("C:\DVD\dustv5.dll")
c=AviSource("E:\jim-yukon-pass2-stabilized-RGB.avi")
UnAlignedSplice(c,BlankClip(c, length=1)) #add 1 frame to end of clip
ConvertToYUY2()
Crop(2,30,-2,-30).Tweak(0.0,0.85,0.0,1.0)
ViewFields()
PixieDust(limit=5)
UnViewFields()
AddBorders(0,32,0,32)
DelayAudio(1.0343677) # 31/29.97 = Deshaker's 30fr lag + Dust 1fr lag
Trim(31,0) #cut first 31 frames which are now empty after Deshaker +1

The PixieDust worked really well cleaning up the chroma flicker and some noise without blurring. It actually seemed to sharpen a little.

Pass3.avs was loaded in VDub, direct stream copy, saved as 27GB HuffyUV YUY2.

Even though I corrected the audio for the AVI, I might as well have not used audio at all in the processing, since the DV audio is 32KHz. I demux'd the original DV file's audio, used Sound Forge to do a highest-quality anti-aliased conversion to 48KHz then remux'd that with my final 27GB HuffyUV file. This file was then dropped into CCE. The resulting MPEG2 was then dropped into TMPGEnc DVD Author.

The DVD came out great (as great as you can get from a shaky 10-year-old dub of a VHS tape). Thanks for the help everybody, esp. scharfi.

scharfis_brain
29th October 2004, 05:11
comment: deinterlacing (fullframerate in this case!) and a following reinterlacing will NOT loose temporal information!

why didn't you get depan working?
weren't my scripts sufficient?
depan requires fullframerate deinterlaced video. separating fields or viewfields won't give satisfying results.

Boulder
29th October 2004, 06:21
You also could have used some other program than CCE for the audio part..BeSweet will beat it any time.

Fizick
29th October 2004, 20:21
scharfis_brain,
Why "depan requires fullframerate deinterlaced video. separating fields or viewfields won't give satisfying results." ?
It works quite well and more fast with separating fields.

scharfis_brain
29th October 2004, 23:46
you are right, for denoising, that may suffice.
( I always feed depan with deinterlaced footage, cause the denoising precision is better.)

but it does not suffice for motion stabilization, because depan or deshaker will try to align the fields, resulting in a halved vertical resolution.

Fizick
31st October 2004, 08:26
Why do you think, that field interpolation in deinterlacer (bobber) is better than compensation in Deshaker (Depan) ?

scharfis_brain
31st October 2004, 12:00
lets assume a non-moving scene.

if I separate the fields,
stabilize them and
afterward weave them,
It would end up with halved vertical resolution, cause the fields had been vertical aligned by the stabilizer.
(this, is the one of the downsides of dynapels steadyhand.
it works with fieldseparated video)

but If you use a bobber (or better: a fullframerate deinterlacer) both fields are blown up to full vertical size with CORRECT alignment.

Fizick
31st October 2004, 22:44
No, if clip is separated by fields, then DePan aligns fields not completly, but with preservation of their spatial difference (1/2 line). It is controlled by "matchfields" parameter and by using Avisynth clip flag IsFieldBased.
I am sure, Deshaker use similar method too.
Do you check it? Or it is your apriory opinion?
Or may be I am still do not understand you.
I think, that fullframerate deinterlacer is good method, but it result in slow processing.
How we can estimate its quantitive adavantage?

scharfis_brain
1st November 2004, 06:10
hmmm. when I tried this matchfields - parameter in past, I found it pretty useless, cause it made the picture going bad.
So I didn't invested more time in it, cause I always feed depan with deinterlaced video (from deshaker).

I will try it again, if my main PC's CPU gets replaced...

communist
2nd November 2004, 10:54
I found PixieDust in combination with CNR2 (great filter imho) to be the most appropriate out of all the denoisers / smoothers I tested or tried to test. I just capped some SVHS footage (shot with an old SVHS camcorder) to HYUV. Although I could have capped it with a miniDV device I went for the bigger files since I wanted to apply some filters etc. Once filtering is done it will be encoded to DV and then edited in native DV NLE, then output to miniDV (for TV display). I used following simple script, which took me quite some time to tweak (AviSynth noob ;) ):

#=============Plugins=============
SetWorkingDir("E:\AVS_filters\")
Loadplugin("ReverseFieldDominance.dll")
Loadplugin("ChromaShift.dll")
LoadPlugin("Undot.dll")
LoadPlugin("cnr2.dll")
LoadPlugin("FixVHSOversharp2_5.dll")
LoadPlugin("LoadPluginEx.dll")
LoadPlugin("DustV5.dll")
LoadPlugin("Msharpen.dll")

#=============Source=============
#ASYNTHER SVHS -> DV25i
AVISource("E:\Caps_HYUV\bridge.avi")
AssumeTFF
SeparateFields

#=============Filtering=============
Cnr2(mode="xxx",scdthr=9,ln=47,lm=192,un=56,um=255,vn=56,vm=255,log=false,sceneChroma=false)
FixVHSOversharp(30,14,10)
ChromaShift(C=0,L=-1)
PixieDust(limit=3)
Undot()
MSharpen(strength=32,threshold=4,mask=false,highq=true)
Weave()
Crop(0,0,0,-12,align=true)
AddBorders(0,0,0,12)
ReverseFieldDominance()
Which gives following results (http://www.stud.uni-goettingen.de/~s304280/D9/pics/denoising_VHS/).
Is there anything that is extremely wrong or am good to go with this script or does anyone have good tips for filters? Because last time I did something similar I made the mistake to mix my analog caps (with TFF) with DV footage (with BFF), I noticed it when I finally did output the project to tape.. ah the horrors :|

scharfis_brain
2nd November 2004, 16:33
your shots are all static (not much visible interlacing)

did you also check for motion smearing artifacts on rapid moving objects?

scharfis_brain
2nd November 2004, 16:46
@Fizick: hm... this matchfields-parameter is working quite well.
I am sorry for making confusion about this.

But as I said, I will probably never use it, cause my video is already progressive, when I feed it into an denoiser (and also depan)

communist
2nd November 2004, 16:56
Yep - havent seen much problems. Most of the other denoisers did have smearing / ghosting but this combo seems to have virtually none. There is only one scene (which I probably wont use anyway) with a more or less fast moving object - that got blurred / smeared into the background. Also the bridge scenes has fast moving cars that leave a little trail which isnt that much of a problem to me.
Before (http://www.stud.uni-goettingen.de/~s304280/D9/pics/denoising_VHS/bridge_fast_before.png)
After (http://www.stud.uni-goettingen.de/~s304280/D9/pics/denoising_VHS/bridge_fast_after.png)
Overall the footage doesnt have that much motion within the scene but more slow panings / zooms which might explain that other filters (spatial and temporal) had smearing / ghosting even with low values.

scharfis_brain
2nd November 2004, 17:10
that's a heavy chroma blur IMO.
I wouldn't smooth it out that strong, cause the tape seems to have already a good quality.

but it's you, who has to be satisfied...

communist
2nd November 2004, 17:37
Yeah I know that I'm heavily denoising - however these are parts I probably wont use. The important parts have bad lighting and lot of chroma noise - hence the strong chroma denoising. This is just an example:
Indoor-Before (http://www.stud.uni-goettingen.de/~s304280/D9/pics/denoising_VHS/indoor_before.png)
Indoor-After (http://www.stud.uni-goettingen.de/~s304280/D9/pics/denoising_VHS/indoor_after.png)

I guess I should start encoding - can take a while ;)

puddy
21st June 2007, 03:22
my way restoring old VHS tapes.

1) load avi in an avs.
1a) add reinterpolate411()
2) bob-deinterlace it to 59.94 fps.
either with tmcbob() or with tdeint(mode=1)
(ELA [edge directed interpolation] is the important thing here)
3)apply a chroma-shift, to shift back the colors to their correctspatial position
4) open this script in VDub.
5) add deshaker
6) run the first pass (don't use RGB, use greyscale!)
AR: NTSC
Frame type: progressive
7) run the 2nd pass
8) save it as HuffYUV.

9) load this deshaked HuffYUV to a 2nd AVISynth-Script.
10) apply a temporal denoiser
10a) preferrable using the function depaninterleave of depan.dll from fizick
11) do further corrections
(saturation, brightness, contrast, hue, sharpness)
12) reinterlace this.

if you have further questions to each step, just ask.

scharfis, are you still using this method or is this outdated now? I'd love to see the June 2007 version of this. Any possibility? :thanks:

Thanks,
puddy

halsboss
23rd June 2007, 02:42
scharfis, are you still using this method or is this outdated now? I'd love to see the June 2007 version of this. Any possibility? :thanks:


Me too. Some people suggest mvdegrain2 variations, however I'd love to see what the masters suggest as the latest.

2Bdecided
20th November 2007, 15:43
Anyone willing to post an update to this?

Cheers,
David.