# Best way to mask dropouts on old Betamax recordings?

1. I'm in the process of transferring a number of 25 year old Betamax videos over to my Mac. I'm currently using an EyeTV 200 box to convert the composite out from the VCR into MPEG 2. My source VCR is a Sony SL-HF360 Betamax. The recordings are a mix of Beta II and Beta III, non-SuperBeta, mono. I do see quite a few white streaks which I am attributing to tape dropout. The severity of these defects varies somewhat. The VCR was recently serviced and does play back commercial tapes quite nicely.

Can anyone recommend a known good way of masking the dropout defects? I've seen references to certain TBCs being able to help somewhat, but I am confused as to which particular units work best. Does anyone have any good suggestions? I need something automatic, as I need to transfer hours of video and can't touch up each frame.

I've attached a picture showing the defects I'm seeing. (White streak in middle of the picture. There is a second one on the right hand side towards the bottom as well)

2. AviSynth's RemoveDirt() filter can remove "comets" like that.

In my experience comets are caused by grounding problems inside the VCR. Often part of the electronics is "floating" and a springy metal flange is used to connect to ground. Cleaning the flange contact or soldering a wire between the grounds can fix the problem at the source.
3. jagabo,

Have you personally used RemoveDirt() to do so? If so, what settings?

I have searched high and low for about 48 hours and I am coming to the conclusion that I am either Googling the incorrect terms, or these drop-out defects have not really been fixed. I have tried DeScratch, which did a great job at removing the telephone-pole cross beams in the distance, but nothing to clear up these pesky white marks.

Most of the forums are filled with very helpful, very polite suggestions. Many of them refuse to say any method is "best," which is a wise policy, in my opinion. However, I have not only failed to find one that is "best," but one which works at all. My sample frame is below ...

4. Yes, I've used RemoveDirt() on a number of occasions. In fact, to be sure it worked on your comets I downloaded your sample file and made a manually fixed copy. I then saved five pictures, four with the fixed image and one, in the middle, with the comet still there. I then used RemoveDirt() and it completely removed the comet (with full motion video it might not work as well).

http://avisynth.org/warpenterprises/files/removegrain_25_dll_20050501.zip

http://home.arcor.de/kassandro/RemoveDirt/RemoveDirt.htm

It can be pasted into your script or you can save it as an importable AVS script and import it into your script.

Your script will look something like:

Code:
function RemoveDirt(clip input, bool "_grey", int "repmode")
{
_grey=default(_grey, false)
repmode=default(repmode, 16)
clmode=17
clensed=Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt=Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode )
restore=Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected=RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
return RemoveGrain(corrected, mode=clmode, modeU = _grey ? -1 : clmode )
}

ConvertToYV12()
RemoveDirt()
You might have to deinterlace before using RemoveDirt(). It also blurs the video a bit so you're much better off if you can fix the problem at the source. If you supply a short sample I'll take a look at it...
5. I must be missing something very silly, at this point ... At least from what I have gathered in the documentation, SCSelect is a function in the DLL's for "repair" and "RemoveGrain." So ... why on earth would I get this error???

6. If you don't have RemoveGrain.dll in AviSynth's plugins folder you have to import it manually in the script.

Code:
LoadPlugin("path\to\RemoveGrain.dll")
7. Jagabo,
Thanks for your help, but I've been using AviSynth for years. I know where the filters go. Also, in the above script, you will notice that "clense" parses fine, but "SCSelect" does not.

I am running out of time to repair this video and my ROI for continuing to search for something that works is quickly running out. It is merely academic curiosity, at this point. Perhaps I'll write a "repair VHS drop-out filter" in CUDA in the next couple of months.

It's really staggering that there are dozens of filters for any defect you can imagine, including removal of logos or time stamps, but not those stupid horizontal lines.
8. It's really staggering that there are dozens of filters for any defect you can imagine, including removal of logos or time stamps, but not those stupid horizontal lines.
Logo removers don't reliably remove a logo anyhow, so they may as well not exist.
9. Update:
Started AVISynth directory from scratch. Pulled "load" statements out of the script. The RemoveDirt plugin now RUNS, but is not catching many of the defects. Small ones get smaller, some disappear, others seem unphased. At least it does seem to have some effect.

I have hours and hours of video with these intermittent marks. As I have come to understand, they are defects in the actual tape, most likely (I have a VCR that works fine for most tapes) and none of them are overly bad, as you can see above. Some sections have 2 or 3 on the screen at once, but none of them are as noisy as some of the examples I have seen while searching for a solution.

Seems to me that finding a solution to target this particular issue should not be that tough algorithmically. Perhaps what I need to do is build a filter similar to "xlogo" that masks the "scratched" area and then interpolates that area instead of running into the potential of blurring more than I intend to ...
10. If I had to guess, it would be that you are using the older .dll versions

http://home.arcor.de/kassandro/prerelease/RemoveGrain-1.0.rar

The .dll's in the package link from warpenterprises that jagabo gave are dated 2005, this newer package are dated 2007

EDIT: oops, I see you figured got it working...sort of... carry on

Cheers
11. Originally Posted by Xpenguin17
It's really staggering that there are dozens of filters for any defect you can imagine, including removal of logos or time stamps, but not those stupid horizontal lines.
Logo removers don't reliably remove a logo anyhow, so they may as well not exist.
They've worked for my purposes, but not what I meant. Only that the VirtualDub and AviSynth worlds are filled with diverse plugins and volumes of code for specific issues, but this particular one only gets "You can use Descratch" or "You can use RemoveDirt" with little explanation beyond. This thread has an actual suggested script and versions of the plugins, for which I am most grateful.
12. Originally Posted by poisondeathray
If I had to guess, it would be that you are using the older .dll versions

http://home.arcor.de/kassandro/prerelease/RemoveGrain-1.0.rar

The .dll's in the package link from warpenterprises that jagabo gave are dated 2005, this newer package are dated 2007

EDIT: oops, I see you figured got it working...sort of... carry on

Cheers
I think in my searching/loading, I must have mixed versions, somewhere. The links above DO work together (work=it runs).
13. Taking a different tack.

The problem in the original post is a tape dropout caused by a magnetic hole in a particular field scan. Professional VTR's correct this (dropout compensation) by monitoring the FM modulation envelope for amplitude drops indicating a dropout. When a dropout is detected they copy pixels from the line above (from line store), previous opposite field (from field store) or from previous same field (frame store).

Since a capture contains previous and post frames, a correction filter should be copying an interpolation of pixels from the previous and following frame.

There are some cases where dropouts last over more than one field such as scratches to the magnetic medium caused by dirt in the guides. In this case the only solution is to interpolate pixels from surrounding pixels in the same field. Professional dropout compensators also do this when RF envelope drops repeat frame to frame.

In the capture case you can't monitor the RF modulation envelope so must use image pattern detection to trigger dropout compensation. This may give false triggers for wide bandwidth video but for VHS/Betamax, the 3MHz luminance filter limits the sharpness of natural pixel transitions. Therefore you can detect oversharp transitions or find single line "holes" that deviate from the line above and line below in the current and/or previous field.

Dropouts don't always produce full white but full white is most noticeable.
14. Originally Posted by edDV
The problem in the original post is a tape dropout caused by a magnetic hole in a particular field scan.
I have a VCR that does this a lot. It's not the tapes because the comets are in different places every time I cap a shot (and in fact, other VCRs play the same tapes just fine.) A few whacks on the side of the machine clears them up for a while (it knocks the grounding flange to a new spot, or maybe just the small motions grind away a little of the corrosion).

I'm not saying this problem is never a dropout on the tape. Only that sometimes it's caused by the player.
15. In this particular case, the drops occur in the same places across multiple captures. Adjusting tracking reduces them, and I have a capture that is about optimal for the VCR I have after a half-dozen runs at it. Frankly, it's a 10 year old tape, so it is what it is. FAR from the worst I've captured.

This is one of those issues like spam e-mail. A human can spot a spam message nearly instantly, but a machine has a tough time figuring it out. That white line may jump out at a retina, but it's just another row of 1's and 0's to Virtualdub. The key is defining a set of rules that say, "This is spam," or "this is a drop-out" and then having the machine do something about it. I do not think it is going to be that tough; I just need to keep looking.
16. Originally Posted by zaq.hack
In this particular case, the drops occur in the same places across multiple captures.
Yes that separates tape issues from player issues. If you see horizontal streaking off vertical edges after guide path cleaning, that indicates worn video heads.
17. Originally Posted by jagabo
Yes, I've used RemoveDirt() on a number of occasions. In fact, to be sure it worked on your comets I downloaded your sample file and made a manually fixed copy. I then saved five pictures, four with the fixed image and one, in the middle, with the comet still there. I then used RemoveDirt() and it completely removed the comet (with full motion video it might not work as well).

http://avisynth.org/warpenterprises/files/removegrain_25_dll_20050501.zip

http://home.arcor.de/kassandro/RemoveDirt/RemoveDirt.htm

It can be pasted into your script or you can save it as an importable AVS script and import it into your script.

Your script will look something like:

Code:
function RemoveDirt(clip input, bool "_grey", int "repmode")
{
_grey=default(_grey, false)
repmode=default(repmode, 16)
clmode=17
clensed=Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt=Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode )
restore=Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected=RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
return RemoveGrain(corrected, mode=clmode, modeU = _grey ? -1 : clmode )
}

ConvertToYV12()
RemoveDirt()
You might have to deinterlace before using RemoveDirt(). It also blurs the video a bit so you're much better off if you can fix the problem at the source. If you supply a short sample I'll take a look at it...
I have made a file "removedirt.avs":
--------------------------------------------
Import("c:\program files\avisynth 2.5\plugins\RemoveDirt.avs")

DirectShowSource("C:\x.mpg")

RemoveDirt()
---------------------------------------------

I open the file with Virtualdub 1.9.5 but an error always shows:

avisynth open failure
script error: Clense does not have a named argument "cache"
(c:\program files\avisynth 2.5\plugins\Removedirt.avs, line 6)
(C:\RemoveDirt.avs)

This is the file c:\program files\avisynth 2.5\plugins\Removedirt.avs:
------------------------------------------------------
function RemoveDirt(clip input, bool "_grey", int "repmode")
{
_grey=default(_grey, false)
repmode=default(repmode, 16)
clmode=17
clensed=Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt=Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode )
restore=Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected=RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
return RemoveGrain(corrected, mode=clmode, modeU = _grey ? -1 : clmode )
}
---------------------------------------
Anyone with a clue?
18. Thank you very much. Got removedirt working now.

The simple script does work:
---------------------------------------------

Import("c:\program files\avisynth 2.5\plugins\RemoveDirt.avs")

DirectShowSource("C:\X\x.mpg")

ConvertToYV12()
RemoveDirt()
----------------------------------------------

however my tests with a video (x.mpg) that has a sharp picture quality show that the output does get blurry with the simple call to RemoveDirt().
The unsharp video will as i see it be hard to make sharper. As is now, i would not like to use the removedirt function because the quality becomes too bad.

Could it be that some of you readers had a script that would utilize removedirt in a way that would do the job without sacrifizing the picture quality?
19. One way may be to look for edge transitions faster than tape luma or chroma bandpass.
20. Replace the last line, "return RemoveGrain(corrected...)" with "return corrected". That will clear things up (and eliminate the grain removal) but transient spots will still be removed. Or better yet, make a copy of RemoveDirt() called RemoveSpots():

function RemoveSpots(clip input, bool "_grey", int "repmode")
{
_grey=default(_grey, false)
repmode=default(repmode, 16)
clmode=17
clensed=Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt=Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode )
restore=Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected=RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
return corrected
}
21. I am new to avisynth but learning all the time.

I made a file "RemoveSpots.avs" in the avisynth plugin folder with your function:

function RemoveSpots(clip input, bool "_grey", int "repmode")
{
_grey=default(_grey, false)
repmode=default(repmode, 16)
clmode=17
clensed=Clense(input, grey=_grey, cache=4)
sbegin = ForwardClense(input, grey=_grey, cache=-1)
send = BackwardClense(input, grey=_grey, cache=-1)
alt=Repair(SCSelect(input, sbegin, send, clensed, debug=true), input, mode=repmode, modeU = _grey ? -1 : repmode )
restore=Repair(clensed, input, mode=repmode, modeU = _grey ? -1 : repmode)
corrected=RestoreMotionBlocks(clensed, restore, neighbour=input, alternative=alt, gmthreshold=70, dist=1, dmode=2, debug=false, noise=10, noisy=12, grey=_grey)
return corrected
}

and imported the file and called like this

ConvertToYV12()
RemoveSpots()

It works fine.
However, I noticed the picture gets slightly darker with the removespots function.
Do you have an idea how to avoid that?
22. Just wanted to say those images look pretty darn good for what they are
23. Originally Posted by tvviewer
RemoveSpots()

It works fine.
However, I noticed the picture gets slightly darker with the removespots function.
Do you have an idea how to avoid that?
I have not seen RemoveSpots() change the brightness of the picture.

I suspect you are comparing your before and after videos by playing them in two media players side by side. Even if both players are playing the same video they will usually look different because one player will be using the graphics card's video overlay feature (which has its own brightness, contrast, color, etc. controls) and the other will be writing directly to the desktop (only one program can use video overlay).
24. Yes, i used two vlc players and played before and after simultanously. I did notice in virtualdub that brightness of before and after looked similar.
Maybe there is no difference.

I will test the method on more sources.
25. Originally Posted by jagabo
AviSynth's RemoveDirt() filter can remove "comets" like that.

In my experience comets are caused by grounding problems inside the VCR. Often part of the electronics is "floating" and a springy metal flange is used to connect to ground. Cleaning the flange contact or soldering a wire between the grounds can fix the problem at the source.
I realize this is an old thread, but I want to add here that this is exactly what was causing these "comets" in my Panasonic AG-1980. I had already cleaned the heads which did not clear this up. On very top of the helical scan head, is a contact in the very center, which is on a leaf spring, as described by jagabo. See the included image. I lifted that contact, viewed with a magnifying glass, and could see a residue. I dabbed a bit of 91% alcohol on a piece of white paper, slipped it under it, wiped it back and forth a couple times, and saw the residue come off. I played the tape, and the picture was clear of all the "comets." Thanks for the tip jagabo. I had just about given up.

CYM.

P.S. I knew it was my deck because on subsequent captures, I could see that the comets were not in the same place each time, so I knew it had to be my deck.
26. i wonder if that is my problem with hi8 camera
Thanks for the tip
27. I think static builds up when the ground leaf spring is corroded. At some point that static arcs and you get a very short flash in in the video signal -- the comet.