PDA

View Full Version : Help needed for improve old cartoon ripped from a VHS source


the_provider
16th April 2008, 23:13
Greetings.

A friend of mine has some tapes from some 10-15 years ago. He searched for those cartoons on the Net but he found nothing. So I helped him rip the tape from VHS.
The big problem is that the look of the video is terrible but reading many posts on this forum made me believe that there is still hope and it can be improved...

Frankly, I don't know what to begin with... I have a decent experience in DVD2avi using GK and I am willing to learn new things but that is all...
I would very much appreciate any advice.
Here http://www.filebox.ro/download.php?key=3aaa27cdf78655ef03cb19bdaf5885c0 you can find a sample, 1 minute long.

Thank you in advance.

Best regards,
The_Provider

Malcolm
17th April 2008, 01:32
This is my attempt: http://www.megaupload.com/de/?d=YDBK8JKH
There is some quality loss due to the quick 'n dirty xvid encoding.
I'm no expert in anime postprocessing, so i haven't used any of the typical 'anime' plugins.
http://img88.imageshack.us/img88/373/dragon1sf9.th.jpg (http://img88.imageshack.us/my.php?image=dragon1sf9.jpg) http://img187.imageshack.us/img187/9025/dragon2gu4.th.jpg (http://img187.imageshack.us/my.php?image=dragon2gu4.jpg) http://img258.imageshack.us/img258/5936/dragon5gq2.th.jpg (http://img258.imageshack.us/my.php?image=dragon5gq2.jpg) http://img88.imageshack.us/img88/2995/dragon6yv5.th.jpg (http://img88.imageshack.us/my.php?image=dragon6yv5.jpg) http://img187.imageshack.us/img187/4855/dragonazv0.th.jpg (http://img187.imageshack.us/my.php?image=dragonazv0.jpg)

DrP
17th April 2008, 03:33
Is that sample what you captured or is it a low bit rate encode of the capture so everyone can see it?

If it is the actual capture file and your device has hardware MPEG2 encoding then the #1 step is to capture at as high a bit rate you can. For video that noisey 4Mbit/sec MPEG2 just isn't going to cut it.

If your capture device doesn't have hardware MPEG2 encoding capture as a lossless (huffyuv) AVI or a high bit rate MJPEG avi (ffdshow, quant = 1 for example).

After you have a 'good' capture file, then you can think about cleaning the video up and doing the final encoding.

fibbingbear
17th April 2008, 06:44
This is my attempt: http://www.megaupload.com/de/?d=YDBK8JKH
There is some quality loss due to the quick 'n dirty xvid encoding.
I'm no expert in anime postprocessing, so i haven't used any of the typical 'anime' plugins.


That's not anime, that's "The Hobbit" when it was animated film back in the old day (or so I think). :)

Malcolm, can you post how you cleaned it up? I'm curious about the filters used.

the_provider
17th April 2008, 07:07
Greetings.

Is that sample what you captured or is it a low bit rate encode of the capture so everyone can see it?

If it is the actual capture file and your device has hardware MPEG2 encoding then the #1 step is to capture at as high a bit rate you can. For video that noisey 4Mbit/sec MPEG2 just isn't going to cut it.

It is indeed the capture file and due to the low quality of the source I thought that a 4MB/s would be more than enough as this is the medium bitrate for DVDs. Can go to as high as 10MB/s(hw MPEG2) though, and will do that if you folks tell me that is mandatory for a better result. The tape is no longer with me and It might take a couple of days until I will have the new file.
Anyway, I am looking forward to seeing the sequence o filters and a "proof of concept" can probably be done with what we have now, isn't it?.

Best regards.
The_Provider

the_provider
17th April 2008, 07:20
This is my attempt: http://www.megaupload.com/de/?d=YDBK8JKH
There is some quality loss due to the quick 'n dirty xvid encoding.
I'm no expert in anime postprocessing, so i haven't used any of the typical 'anime' plugins.

Greetings.

Your sample is pretty impressive.
Please share with us how did you do it.
But hey, are you saying that it can be improved further?
Wow, I am looking forward to seeing the magic...

Best regards,
The_Provider

Malcolm
17th April 2008, 10:25
That's not anime, that's "The Hobbit" Did i say it's anime? I don't think so! Read my sentence carefully! ;)
Nevertheless, avisynth and the plugins don't care if it's japanese 'cartoons' or from a different place in the world! :D

DrP
17th April 2008, 21:10
It is indeed the capture file and due to the low quality of the source I thought that a 4MB/s would be more than enough as this is the medium bitrate for DVDs.

My comments were based on the amount of 'blocking' in the sample you provided. If you can get the tape again and grab it at the highest bit rate you can, you should reduce the amount of blocking which gives you less to clean up afterwards.

the_provider
18th April 2008, 01:05
My comments were based on the amount of 'blocking' in the sample you provided. If you can get the tape again and grab it at the highest bit rate you can, you should reduce the amount of blocking which gives you less to clean up afterwards.

I understand.
But, as I said, I have no experience in identifying the flaws of the movie as in I don't now what do you call "blocking", for instance. Therefore I am not able at this point to analyze the video and then choose a combination of filters that will improve it. Deringing, demasking and so forth are just words for me, I can't spot/recognize them in a video. I can just say that it looks ugly...:confused:

That is why I am kindly asking Malcolm and anyone else to paste the script :script::script: he used for my sample here, in this thread.

And maybe some links too where all these concepts used in video editing are explained with pictures...

Best regards.

fibbingbear
18th April 2008, 01:32
I understand.
But, as I said, I have no experience in identifying the flaws of the movie as in I don't now what do you call "blocking", for instance. Therefore I am not able at this point to analyze the video and then choose a combination of filters that will improve it. Deringing, demasking and so forth are just words for me, I can't spot/recognize them in a video. I can just say that it looks ugly...:confused:


You might try looking at these guides from Anime Music Video. Even though it's not anime, as Malcolm points out, it'll work well for cartoons. If nothing else, it'll help show what some of the words mean:

One guide (older):
http://www.animemusicvideos.org/guides/avtech/avspostqual.html

Another guide (newer):
http://www.animemusicvideos.org/guides/avtechbeta/avspostqual.html

Although I use FFT3DFilter instead of the 3D Filter they use in the guide, and I think VMToom has superceded MFToon.

And as everyone else has already said on this forum, Malcolm :script:

Malcolm
18th April 2008, 09:57
And as everyone else has already said on this forum, Malcolm :script:

Ok! Ok! I will! :)
But you'll have to wait until the weekend. It's a bit 'rough' at the moment ;)

Malcolm
18th April 2008, 22:56
O.k. here is the script.
It's a simplified version of my VHS processing script. It's intended for very old and dirty VHS recordings. But as you can see it works nicely with this source too.
Although it's simplified it still uses loads of RAM when it's executed. As you can imagine it's sloooooowwww! :)
All used functions are included in the script with the exception of mc_spuds. But you can find it in the forum.

It's fun to watch the output frame by frame and compare it to the original! ;)

setmemorymax(1024)
#import needed scripts
Import("C:\Programme\Videotools\AviSynth 2.5\plugins\" + "mc_spuds.avs")
# Load the video
mpeg2source("Flying_Dragons_split1.d2v",cpu2="ooooox",info=3)

# Crop for faster preview, remove before encoding
crop(0,0,432,-0)

# Save for later comparison
orig = last

# Heavy deblocking
deblock(quant=51)

# Add borders. Remove later to hide some green artifacts
addborders(4,0,4,0)

# Remember vinverse for later use
saved = vinverse()

# Remove VHS colorshift
Vshift=2 # 2 pixels per tape generation
Hshift=0
#mergechroma(last.crop(Hshift,Vshift,0,0, align=true).addborders(0,0,Hshift,Vshift))

# Remove large horizontal stripes
#turnleft()
#descratch(mindif=12, maxgap=170, minlen=25, blurlen=5, keep=100, border=0, maxangle=1, modey=2)
#turnright()

# Remove Colorbleeding
RemoveColorBleeding()

# Derainbow
DeRainbow()

# Motion compensated denoise & Sharpen
MC_Spuds(strength=6, frames=3, flow=false, focus=false, preprocess=true, postprocess=true, temporal=true)
soothe_local(saved.mergechroma(last), last, 10)

# Fizzkiller
fizzkiller3(blksize = 16, sharp = 2, overlap=4)

# Vinverse
vinverse()

# Sharpen
a=degrainmedian(mode=2).VagueDenoiser(threshold=0.8, method=1, nsteps=6, chromaT=0.8)
SeeSaw(last, a, NRlimit=6, NRlimit2=7, Sstr=1.5, Slimit=5, Spower=5, Sdamplo=6, Szp=16)
limitedsharpenfaster(strength=300,overshoot=0, Smode=4, soft=-1)

# Add grain
AddGrain(8,0,0)

# Remove added borders from above
crop(4,0,-4,-0)

# Show original clip & difference
clipA = last
diffRate = 16
d_clipA = subtract(orig, clipA).levels(127-diffRate,1,128+diffRate,0,255)
stackhorizontal(clipA, d_clipA)
stackhorizontal(orig, last)

converttoyuy2()
return last


### Functions ###

# RemoveColorBleeding (by Didée)
function RemoveColorBleeding(clip input) {
o=input
warp1=o.mergechroma(o .blur(1.0).unsharpmask(255,1,1).aWarpSharp(depth=20.0, thresh=0.75, blurlevel=3, cm=1))
warp2=o.mergechroma(warp1.blur(1.0).unsharpmask(255,1,1).aWarpSharp(depth=12.0, thresh=0.75, blurlevel=2, cm=1))
# interleave(o,warp1,warp2) # visualization
return warp2
}

# DeRainbow (by sh0dan)
function DeRainbow(clip org, int "thresh") {
assert(org.isYV12(),"DeRainbow() requires YV12 input!")
thresh = default(thresh, 10)

org_u = utoy(org)
org_v = vtoy(org)

msharpen(org, threshold = thresh, mask=true)
reduceby2()
greyscale()
uv = blur(1.5).levels(0,2.0,255,0,255, coring=false).blur(1.5).blur(1.5).levels(50,2.0,255,0,255, coring=false)

filtered_u = org_u.mipsmooth(spatial=255, temporal=255, scenechange=3, show=false, method="strong", scalefactor=0.5)
filtered_v = org_v.mipsmooth(spatial=255, temporal=255, scenechange=3, show=false, method="strong", scalefactor=0.5)

u_final = MaskedMerge(org_u, filtered_u, uv)
v_final = MaskedMerge(org_v, filtered_v, uv)

return ytouv(u_final, v_final, org)
}

# Fizzkiller3 (by Jawed)
function FizzKiller3(clip source, int "blksize", int "overlap", int "sharp", int "thSAD") {
# Motion compensated denoiser for progressive source clip with prefiltering optimised to reduce high-contrast noise
# Uses MVTools and RemoveGrain

blksize = default(blksize,8) # blksize value (4, 8 or 16)
overlap = default(overlap,blksize/2) # overlap value (0 to half blksize)
sharp = default(sharp,1) # 0=bilinear softest, 1=bicubic, 2=Wiener sharpest
thSAD = default(thSAD,400) # higher risks motion ghosting and swimming, lower risks blotchy denoising

#idx = 20 # "safe" idx for use within this function only

# Prefilter the clip
calm = source.invert("Y").levels(0, 0.5, 255, 0, 255, coring = false)
calm = calm.removegrain(mode = 17)
calm = calm.removegrain(mode = 17)
calm = calm.removegrain(mode = 17)

backward_vec3 = calm.MVAnalyse(isb = true, delta = 3, pel = 2, blksize=blksize, overlap=overlap, sharp=sharp, idx = idx)
backward_vec2 = calm.MVAnalyse(isb = true, delta = 2, pel = 2, blksize=blksize, overlap=overlap, sharp=sharp, idx = idx)
backward_vec1 = calm.MVAnalyse(isb = true, delta = 1, pel = 2, blksize=blksize, overlap=overlap, sharp=sharp, idx = idx)
forward_vec1 = calm.MVAnalyse(isb = false, delta = 1, pel = 2, blksize=blksize, overlap=overlap, sharp=sharp, idx = idx)
forward_vec2 = calm.MVAnalyse(isb = false, delta = 2, pel = 2, blksize=blksize, overlap=overlap, sharp=sharp, idx = idx)
forward_vec3 = calm.MVAnalyse(isb = false, delta = 3, pel = 2, blksize=blksize, overlap=overlap, sharp=sharp, idx = idx)
source.MVDegrain3(backward_vec1, forward_vec1, backward_vec2, forward_vec2, backward_vec3, forward_vec3, thSAD = thSAD, idx = idx + 1)
}

# Soothe (by Didée)
function Soothe_local(clip sharp, clip orig, int "keep") {
Assert(sharp.width == orig.width && sharp.height == orig.height,
\ "Soothe: clip dimentions must match!")
keep = default(keep, 24)
keep = (keep>100) ? 100 : (keep<0) ? 0 : keep
KP = string(keep)
diff = mt_makediff(orig,sharp)
diff2 = diff.temporalsoften(1,255,0,32,2)
diff3 = mt_lutxy(diff,diff2, "x 128 - y 128 - * 0 < x 128 - 100 / " + KP
\ + " * 128 + x 128 - abs y 128 - abs > x " + KP
\ + " * y 100 " + KP + " - * + 100 / x ? ?")
return( mt_makediff(orig,diff3,chroma="copy first") )
}

Malcolm
18th April 2008, 22:57
@ the_provider
You should do as said and capture the vhs tapes again at a bitrate as high as possible. The best would be a lossless capture. Although i made the experience in the past that my DVD-recorder captures better looking videos than my capture card. (sharper, better colours). Also sometimes DVD-recorders have circuits to handle weak signals better than a cheap (read 'all') capture cards.

the_provider
19th April 2008, 02:14
O.k. here is the script.
Wow! I am really, really stunned! Thanks a lot!

It's a simplified version of my VHS processing script.
SIMPLIFIED? Good Heavens, how does the FULL version look like?

It's intended for very old and dirty VHS recordings. But as you can see it works nicely with this source too.
Although it's simplified it still uses loads of RAM when it's executed. As you can imagine it's sloooooowwww! :)
All used functions are included in the script with the exception of mc_spuds. But you can find it in the forum.

It's fun to watch the output frame by frame and compare it to the original! ;)

setmemorymax(1024)...

Seriously, how can one reach this level of craftsmanship? How much time is needed?
And did I mentioned how stunned I am?
What about the computer you use, 2 or 4 cores and how much RAM? Preferred dubbing software would be...?


All the best and thank you again.

Malcolm
19th April 2008, 12:30
Wow! I am really, really stunned! Thanks a lot!
You're welcome.
Actually i just have compiled the functions & plugins some genious guys (mentioned in my script) have created to a meaningful combination. Still - this was a task that took months of tweaking. For example, the order in which the functions are called is very important and influences the output quality a lot! And i don't mean obvious thinks like sharpening at the end and so on..
Also obviously the parameters used are key!
There are some lines commented out, like descratch and compensation of tape-generation color shift. I don't find them necessary atm. but you can decide yourself. Actually, the source is _that_ bad, i can't figure out which parameters i should choose to compensate color shift! ;)
If you can make another capture with less blocking, you can comment-out the deblocking call (or use "xxxxox" for cpu2 in mpeg2source). Interestingly it's not that important anyway since the following stuff like denoising and so on also 'removes' the blocks quite good.
Also, if your new capture is of higher quality (i guess with a higher bitrate you will preserve a lot more details), the denoising doesn't have to be that strong (it kills some details (blurs edges) atm.). lower the 'strength' value in mc_spuds. You could also comment-out Fizzkiller3 as it blurs the picture somewhat (but on the other hand 'straightens' the picture where it's distorted).

My VHS script has things like motion compensated bobbing, which is slow per-se but also doubles the number of frames (= twice the time needed), also stabilizing of camera shake (very slow), deringing, Halo removal (slow) and some other thinks like dotcrawl removal and colour corrections.

I processed 17 VHS captures recently with around 45 minutes each and it took 18 hours per capture (~1fps). This was done on a Core2Duo @2.6GHz with 2GB RAM. My PC at home is a Core2Duo @3.15GHz with 2GB RAM.