Log in

View Full Version : Using DeScratch


Keith R
2nd August 2019, 06:21
Hi All, I'm new to this forum , so please forgive my ignorance if I ask silly questions. I have a bunch of VHS and Video 8 tapes to digitize and I would really like to get rid of some of the horizontal dropout streaks from old tapes. I also plan to be converting one of my old 8 mm film projectors so I really need to understand AviSynth. I am a retired electronics technician from the analog world with some programming knowledge from the old Apple 2 days and for the last 10 years , I have been programming PIC chips, so I have a small knowledge of programming languages and scripts.

I've tried using DeScratch with VurtualDub but maybe I'm sticking the .dll file in the wrong folder or something because I do not see any change in the dropouts. I did manage to use a few of the other scripts successfully but I just can't figure out DeScratch. I would really appreciate some help. I've attached two pics of the problem. Thanks very much.

Keith R

StainlessS
2nd August 2019, 10:24
DeScratch is for longish vertical streaks, so would require at least an eg "Turnleft ... Descratch ... Turnright ...".

attachments take som time to appear, but maybe this is similar example:- https://forum.doom9.org/showthread.php?t=174422&highlight=Flaw+Logic+Motion+Compensated

and see post #7.

johnmeyer
2nd August 2019, 12:02
I've had better luck with DeSpot, although it is difficult to tune. Here is the function I made for it to remove VHS dropouts. You will have to read the DeSpot documentation and you will have to alter the settings I used. Also, no matter what, it isn't perfect.

So, without any warranty, here is some code. "Remove_TearsI" is the interlaced front end to Remove_Tears. Since I always keep my VHS captures interlaced, I use this front end.

function Remove_TearsI(clip source)
{

ml = 100 # mask scale
scene_change = 200 # scene change

fields=source.SeparateFields()
even_fields=selecteven(fields)
odd_fields =selectodd(fields)

even_result_fields = RemoveTears(even_fields,ml,scene_change)
odd_result_fields = RemoveTears(odd_fields, ml,scene_change)

#=================
#Put even and odd fields back together into interlaced video

interleave(even_result_fields,odd_result_fields)
weave()

} # End Function RemoveTearsI

function RemoveTears(clip source, int ml, int scene_change)
{
show=0
tsmooth=0
p1percent=2
dilate=20
maxpts=0
p2=12
mthres=16
p1=24
pwidth=100
pheight=12
mwidth=7
mheight=5
merode=33
interlaced=false
seg=1
sign=0
ranked=true

super = MSuper(source,hpad=16, vpad=16, pel=2, sharp=1)

vb = MAnalyse(super,isb = true, blksize=8,overlap=4,search=3,dct=0) # backward vectors
vf = MAnalyse(super,isb = false, blksize=8,overlap=4,search=3,dct=0) # forward vectors

cb = MFlow(source,super,vb,thSCD1=scene_change) # next compensated backward
cf = MFlow(source,super,vf,thSCD1=scene_change) # previous compensated forward

sadf = MMask(super,vf, ml=ml,kind=1,gamma=1, thSCD1 = scene_change)
msadf= sadf.Binarize() # binary inverted forward SAD mask

sadb = MMask(super,vb, ml=ml, gamma=1, kind=1, thSCD1 = scene_change) # backward SAD mask
msadb= sadb.Binarize() # binary inverted backward SAD mask

msad = Logic(msadf,msadb,"OR") # combined inverted SAD mask
msad = msad.Expand() # expanded inverted SAD mask
msadi = Interleave(msad, msad, msad) # interleaved 3-frame inverted SAD mask

Interleave(cf,source,cb) # interleave forward compensated, source, and backward compensated

DeSpot(show=show,extmask=msadi,tsmooth=tsmooth,p1percent=p1percent,dilate=dilate,maxpts=maxpts,p2=p2,\
mthres=mthres,p1=p1,pwidth=pwidth,pheight=pheight,mwidth=mwidth,mheight=mheight,merode=merode,\
interlaced=interlaced,seg=seg,sign=sign,ranked=ranked).SelectEvery(3,1)

}

Keith R
2nd August 2019, 15:48
Thanks John, Hmmm....John Meyer?? Do you play a mean guitar and sing?? O.K. jokes aside, the script looks good, but would you mind just explaining how to use it in simple steps please? Sorry but I did say that this was new to me. Thanks again!

Keith R

real.finder
2nd August 2019, 16:40
I used RemoveDirtMC_SE for remove Tears and it did the job

StainlessS
2nd August 2019, 18:15
how to use it in simple steps

With Johns posted script also inserted somewhere into your script [here we just formatted a little, makes it a lot easier to understand and see that it is 2 script functions.

Function Remove_TearsI(clip source) { # Interlaced
ml = 100 # mask scale
scene_change = 200 # scene change
fields=source.SeparateFields()
even_fields=selecteven(fields)
odd_fields =selectodd(fields)
even_result_fields = RemoveTears(even_fields,ml,scene_change) # Calling the Progressive function for each of the interlaced fields
odd_result_fields = RemoveTears(odd_fields, ml,scene_change) # Ditto
#=================
#Put even and odd fields back together into interlaced video
interleave(even_result_fields,odd_result_fields)
weave()
} # End Function RemoveTearsI


Function RemoveTears(clip source, int ml, int scene_change) { # Progressive
show=0
tsmooth=0
p1percent=2
dilate=20
maxpts=0
p2=12
mthres=16
p1=24
pwidth=100
pheight=12
mwidth=7
mheight=5
merode=33
interlaced=false
seg=1
sign=0
ranked=true
super = MSuper(source,hpad=16, vpad=16, pel=2, sharp=1)
vb = MAnalyse(super,isb = true, blksize=8,overlap=4,search=3,dct=0) # backward vectors
vf = MAnalyse(super,isb = false, blksize=8,overlap=4,search=3,dct=0) # forward vectors
cb = MFlow(source,super,vb,thSCD1=scene_change) # next compensated backward
cf = MFlow(source,super,vf,thSCD1=scene_change) # previous compensated forward
sadf = MMask(super,vf, ml=ml,kind=1,gamma=1, thSCD1 = scene_change)
msadf= sadf.Binarize() # binary inverted forward SAD mask
sadb = MMask(super,vb, ml=ml, gamma=1, kind=1, thSCD1 = scene_change) # backward SAD mask
msadb= sadb.Binarize() # binary inverted backward SAD mask
msad = Logic(msadf,msadb,"OR") # combined inverted SAD mask
msad = msad.Expand() # expanded inverted SAD mask
msadi = Interleave(msad, msad, msad) # interleaved 3-frame inverted SAD mask
Interleave(cf,source,cb) # interleave forward compensated, source, and backward compensated
DeSpot(show=show,extmask=msadi,tsmooth=tsmooth,p1percent=p1percent,dilate=dilate,maxpts=maxpts,p2=p2,\
mthres=mthres,p1=p1,pwidth=pwidth,pheight=pheight,mwidth=mwidth,mheight=mheight,merode=merode,\
interlaced=interlaced,seg=seg,sign=sign,ranked=ranked).SelectEvery(3,1)
}

### End Of Johns script functions

AviSource(...) # your source filter. Implicitly assigns clip to special Last variable

# For Interlaced source
#Return Remove_TearsI() # Implicitly called with special variable clip Last. The end of script for Interlaced [commented out if not interlaced]

# For Progressive source

# Below simply taken from inside Johns Remove_TearsI function,
ml = 100 # mask scale
scene_change = 200 # scene change

RemoveTears(ml,scene_change) # Implicitly called with special variable clip Last. # EDIT: Oops, was Remove_TearsI

Return Last # The end of script for Progressive


The items in red are MVTools arguements, see docs for MvTools.
The Items in Blue, are DeSpot args, see DeSpot [and may not need be changed, although I think that john has a habit of temporarily changing args in-situ for special circumstance).

Also of course need DeSpot and MvTools dlls.

Keith R
3rd August 2019, 10:40
Thanks Guys, I'll have a go at this and report back!

Keith R

Keith R
9th August 2019, 13:20
O.K. I tried all of this stuff without success. It's all a bit above my old brain I'm afraid. I did get some other advice from a few other forums. After a lot more trial and error, and loads of frustration (gave up a few times!) I came across RgTools in the AviSynth Wiki. I eventually used a simple script with a few lines to enable the RgTools filter and I fixed my bad video enough to make it more than watchable. I've attached a before and after pic to see. I can tell you that this video was really full of streaks all over and this fix worked. I captured the original footage as an Mpeg 2 file and to use the script in VideoDub 2, I converted the footage to an AVI file. I still need to re-edit the entire clip which I prefer to do in Power Director, but after many weeks of trying to undertand the AviSynth involved scripts and protocols, this works so well for me, and I did not have to get involved with that very steep learning curve.

Here is my .avs script:

LoadPlugin("RgTools.dll")
DirectShowSource("Location and name of your video to fix.avi")
ConvertToYV12()
input=last
AssumeTFF()
RemoveGrain
Clense

I put the RgTools.dll file in the same folder that I saved the above script in. If anyone needs to know the whole setup, then I can post it here. I also ran the deinterlace filter in VirtualDub at the same time and now I will just edit the whole clip properly and stick it on a DVD for my friends. This is so great and will fix most of my bad footage. I can still see the incredible power of AviSynth so I will plug on and try to learn the more advanced stuff later. Thanks for the help guys!

Keith R

LemMotlow
10th August 2019, 03:08
What the hell do you expect us to do with still images? Don't you know how to make video samples? If you don't, why not ask?

Are they just getting thicker out there, or what?

johnmeyer
10th August 2019, 04:39
Are they just getting thicker out there, or what?Probably not, but you are sure getting snarkier.

The guy's a newbie and trying to get his first script to run. True, he didn't post a video clip, but no one asked him for that.

Keith R
10th August 2019, 06:33
Wow.....let me try that again. Lem, no need to get nasty. I am not used to forums that allow big files, and the drop-out streaks are just like dirty heads, damaged tape etc. As John rightly said, I am indeed a newbie and at 69 years of age, I don't learn as fast as I did when I was younger. After I posted the above comments, I found that it is the "Clense" function that removes the streaks. I also found that the overall quality of the video in terms of speed of movement, maybe the word is "dithering", became worse, so as I stated, I still need to learn a lot. Hopefully there are more "patient" folks out there on this forum than LemMotlow. To JohnMeyer and StainlessS, my grateful thanks!

Keith R

Groucho2004
10th August 2019, 10:32
Hopefully there are more "patient" folks out there on this forum than LemMotlow.There certainly are. There was another useless post from him a few hours ago. He probably didn't get laid in a while.

StainlessS
10th August 2019, 14:23
Oops sorry, edit in prev post#6

RemoveTears(ml,scene_change) # Implicitly called with special variable clip Last. # EDIT: Oops, was Remove_TearsI

Keith R
10th August 2019, 16:58
Thanks guys, for sure there just has to be at least one unhappy character on forums, but it is nice to know that you guys are there to help. So to post a video, do I just stick it on YouTube or Vimeo and post the link here?

Keith R

johnmeyer
10th August 2019, 17:45
The purpose of uploading a video clip is so people can look at exactly what you are dealing with. I emphasized that word because uploading to YouTube, while easy to do, completely alters the video (they re-encode and do other things when streaming). Also, if you re-encode as part of cutting the clip (so you only have 5-10 seconds to keep the upload small), then you have also altered it.

The easiest thing is to download VirtualDub2 and use it to cut your video down to a short clip. It is generally best to pick a clip that has some actual motion (i.e., no video of grandma sitting in a chair talking). You put the video on the timeline, select "Direct Stream Copy" from the video menu, create your "in/out" points (i.e., where you will cut the video), and then save that clip.

You can then upload that to any site that lets other people download the file. Someone else will have to give you a list of what people are using today. I'm only a couple of years younger than you, and some of my favorites from the past are no longer useful. I think you can still use Mediashare, and you might be able to use Google Drive, although I don't know if they permit widespread sharing.

Groucho2004
10th August 2019, 17:53
So to post a video, do I just stick it on YouTube or Vimeo and post the link here?You should post to a file hosting site such as dropbox or mediafire. The clip must be an unprocessed sample from the original.

If the clip is too big you can cut it, there are several tools to do that for various file types. We would need to know what exactly you're working with in order to suggest a cutting tool.

Edit - John was faster and added an alternative approach. See what works best for you.

Keith R
11th August 2019, 07:36
https://youtu.be/AmVsWSWwrck

Thanks Guys, I stuck a YouTube link here in the meantime, just to illustrate the difference. I captured the footage in Mpeg2 using my Power Director 13 software. I'm actually trying to put together a story about our model plane club so instead of running through old tapes, I just dump all of the tapes to a hard drive. I have many hours of footage to look through to create shot lists so I figured that having them in a non-linear format is the best way to do this quickly. Of course what happened here is that I come across footage of family and friends and get side-tracked!

I will try to capture the bad footage again in VirtualDub using a lossless format. So for now, I am really happy about AviSynth and the help on this forum.:o

Keith R