Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th April 2010, 10:10   #1  |  Link
bololo
Registered User
 
Join Date: Aug 2007
Posts: 25
need help on repair old anime

Hello Everyone!

I would like to learn how to use Avisynth and all the filters arround to repair/improve my collection of old anime.

I would like to make my first try on "Arupusu no Shōjo Haiji" which is from 1974 and it is extreme noisy and suffers some shaking.
Furthermore this anime suffers spotting and also dark lines are too bright for my taste.

For getting an idea of this toon, here a lossless compressed sample (34 MB, codec:FFV1)
http://rapidshare.com/files/376022232/sample.avi
Edit:Another sample direct from the source
(15 MB, mpeg2):
http://rapidshare.com/files/376421612/sample_cut.mpv

Edit: My avisynth-Script (you may have to adjust the path for the filters)
Code:
# Set DAR in encoder to 4 : 3. The following line is for automatic signalling
global MeGUI_darx = 4
global MeGUI_dary = 3

AviSource("sample.avi")

### colorcorrection
LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\ColorMatrix.dll")
ColorMatrix(hints=true, threads=0)


### anitflicker
loadplugin("deflicker.dll")
DeFlicker(scene=30)

###linedarken
Import("FastLineDarken.avs")
FastLineDarken(strength=128)

### DeDot
TComb(mode=2,fthreshl=10,fthreshc=20,othreshl=5,othreshc=6,map=false,scthresh=12.0)


### crop
crop( 14, 2, -10, -2)

###Saturation
Tweak(sat=1.1, bright=-30, cont=1.1)


### Denoise
LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\Convolution3DYV12.dll")
Convolution3D("animeBQ")
#----- eDeen(r=2, ty=20, tuv=30, ly=2, luv=3, hqc=true)
FFT3DFilter(sigma=2.0, plane=4, bw=48, bh=48, bt=4, ow=16, oh=16, sharpen=1, interlaced=false)
 
#ConvertToYV12()

#deSpot
i=ConvertToYV12()
d = DePanEstimate(i,trust=3)
DePanInterleave( data=d)
DeSpot(p1=30, p2=15, pwidth=800, pheight=600, mthres=20, motpn=true, dilate=1, seg=1, color=true,ranked=true)
SelectEvery(3, 1)


### deshake
Import("Stab.avs")
Stab()

 	 	
### 3rd party filter
LoadVirtualDubPlugin("MSU_cartoon_restore.vdf","MSUCartoonRestore", 0) 
ConvertToRGB32.MSUCartoonRestore("bilateral", 2, 4, 30)
    
ConvertToYV12()

###Sharpen
aWarpSharp2(depth=20,type=0,blur=4,thresh=128,chroma=4)
MSharpen(threshold = 15, strength = 100)

###duplicate frames
Dup(threshold=3,blend=false,copy=true,chroma=false,blksize=8,show=false)
Edit: Now i am satisfied

But i am not satisfied with the result, so i beg for your help:
I cant fix this x and y shaking, and the areas of same colour still have noise.

Do you have any suggestions or hints for me?
I played arround with all this disabled (#) filters in the script but i failed to find good settings - maybe you have an idea?

greetings,
bololo

Last edited by bololo; 19th April 2010 at 09:07.
bololo is offline   Reply With Quote
Old 15th April 2010, 12:50   #2  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 949
I cant help you with the deshake because Im having the same problems as you. Your source has many similarities with film artifacts so taking a glance to the 8mm restoration thread could give you many clues.
If I was you I'd go with a script in this fashion:

Quote:
setmemorymax(768)
SetMTmode(5)
AVISource("sample.avi")
SetMTmode(2)
crop(16,2,-12,-2)

tdecimate()
#Color Correction here. I'd use Gicocu

#Deshaker here

#Despot here
MDegrain(800)
deen("w3d")

Dup(threshold=7,blend=false,copy=true,chroma=false,blksize=8,show=false)

lanczos4resize(704,576)
aWarpSharp2(depth=10,type=0,blur=4,thresh=128,chroma=4)

LSFmod(defaults="slow", strength=40, edgemode=2,soothe=false,overshoot=2) #Sharpen backgrounds
You should have to play with the values, in the color correction process you should also have to care for the luma flicker. MDegrain(800) is a function I just made for myself, and 800 is thSAD value. It would better if you upload the source file, the same section in .m2t format from DGindex. At last you should set the correct DAR or PAR having into account the cropping you just made. I have made a formula for that here. For line darkening I use mftoon, but I wouldnt see if I need it until the color correction is made. The tdecimate there removes all dupes (apparently 1 every 5 frames), leaving a 20fps framerate.

You may also want to use an All-in-one script if you want the easy way out, like MCSpuds or MCtemporaldenoise.

Last edited by Dogway; 15th April 2010 at 17:23.
Dogway is offline   Reply With Quote
Old 15th April 2010, 17:04   #3  |  Link
lansing
Registered User
 
Join Date: Sep 2006
Posts: 805
sometime ago I started a thread about this shaking problem with old japanese anime, and end up with this. I tested on your sample and it seems to work well, just make sure to apply it after you remove the flicker.
lansing is offline   Reply With Quote
Old 16th April 2010, 06:49   #4  |  Link
bololo
Registered User
 
Join Date: Aug 2007
Posts: 25
@lansing : big thx for your reply, but too bad i can not test your solution, as i can not load FFT3D.dll, nor few others (eg VariableBlur.dll) I think its a Windows7 x64 issue...

@dogway : i will have a look into your advices, thank you for that.
also i uploaded another example direct from the mpg2:

(Sample 15 MB, mpeg2):
http://rapidshare.com/files/376421612/sample_cut.mpv
bololo is offline   Reply With Quote
Old 16th April 2010, 14:58   #5  |  Link
DarkNite
Almost Silent Member
 
DarkNite's Avatar
 
Join Date: Jun 2002
Location: Purgatory
Posts: 271
Strange... I'm running Win7 x64 and both FFT3DFilter and FFT3DGPU work perfectly here. Have you installed the FFTW libraries?

Quote:
Filter uses fast external FFTW library version 3 (http://www.fftw.org)
as Windows binary DLL (compiled with gcc under MinGW by Alessio Massaro), which support for threads and have AMD K7 (3dNow!) support in addition to SSE/SSE2.
It may be downloaded from ftp://ftp.fftw.org/pub/fftw/fftw3win32mingw.zip
You MUST put FFTW3.DLL file from this package (not fft3dfilter.dll) to some directory in path (for example, C:\WINNT\SYSTEM32).
Filter will NOT work without it!
I have put the fftw3.dll in my Windows\SySWOW64 directory.
__________________
Rethinking the "Why?" chromosome.
DarkNite is offline   Reply With Quote
Old 16th April 2010, 15:27   #6  |  Link
osgZach
Registered User
 
Join Date: Feb 2009
Location: Waterloo, WI - USA
Posts: 650
on x64 platforms SySWOW64 is for 32-bit stuff. So if its a 32-bit filter, make sure it goes there.
osgZach is offline   Reply With Quote
Old 18th April 2010, 12:01   #7  |  Link
bololo
Registered User
 
Join Date: Aug 2007
Posts: 25
After putting the files into the SySWOW64-folder everything runs fine! Thank you!

After much testing i decided to use a modified Stab() function to stabilize the picture. It works quite good.

Code:
##############################################################################
#Original script by g-force converted into a stand alone script by McCauley  #
#latest version from December 10, 2008                                       #
#modified for fill up black edges by bololo                                  #
##############################################################################

function Stab (clip clp, int "range", int "dxmax", int "dymax") {

range = default(range, 1)
dxmax = default(dxmax, 4)
dymax = default(dymax, 4)

temp  = clp.TemporalSoften(7,255,255,25,2)
inter = Interleave(temp.Repair(clp.TemporalSoften(1,255,255,25,2)),clp)
mdata = DePanEstimate(inter,range=range,trust=0,dxmax=dxmax,dymax=dymax)

DePan(inter,data=mdata,offset=-1, mirror=15, blur=30)
#DePanStabilize(inter, data=mdata, dxmax=4, dymax=4, rotmax=0, zoommax=0)

SelectEvery(2,0) }
So my current script is:

Code:
loadplugin("deflicker.dll")
DeFlicker(scene=30)

### DeDot
TComb(mode=2,fthreshl=10,fthreshc=20,othreshl=5,othreshc=6,map=false,scthresh=12.0)


### crop
crop( 14, 2, -10, -2)

###Saturation
Tweak(sat=1.2)

### Denoise
LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\Convolution3DYV12.dll")
Convolution3D("animeLQ")
### need more denoise!
FFT3DFilter(sigma=2.0, plane=4, bw=48, bh=48, bt=4, ow=16, oh=16, sharpen=1, interlaced=false)

###Sharpen
aWarpSharp2(depth=20,type=0,blur=4,thresh=128,chroma=4)

### deshake (modified as the listing above)
Import("Stab.avs")
Stab()

###Eliminate duplicate pictures
Dup(threshold=4,blend=false,copy=true,chroma=false,blksize=8,show=false)
I will test some orderchanges, but the result does not look too bad compared to the sh|tty source...

regards,
bololo

Last edited by bololo; 18th April 2010 at 16:09.
bololo is offline   Reply With Quote
Old 18th April 2010, 16:02   #8  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 949
dup doesnt eliminate any dups as long as I know. It just convert dups into the same frames (copy) for bitrate economy. For eliminate dups (decimation) use Decimate, or TDecimate and look for a dup repetition pattern.
Dogway is offline   Reply With Quote
Old 18th April 2010, 16:09   #9  |  Link
bololo
Registered User
 
Join Date: Aug 2007
Posts: 25
Okay, but that causes a problem:
Because of the many spots not all duplicated frames are detected. I think only 60-70% of duplicated frames are detected.

So if only those detected duplicates are getting removed wouldnt that cause problems to the framerate like causing a variable framerate?

regards,
bololo
bololo is offline   Reply With Quote
Old 18th April 2010, 18:29   #10  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 949
of course. Anime originally has frame duplication, even in the source 24fps, its animation economy. You shouldnt aim to remove all the dups, just those introduced through the 24fps ->29.976/25. The rest kind of dups inherent to the animation can be then used for the Dup filter. This will only make your video play at original 24fps, no variable framerate. I think that ideally you should use srestore (which removes necesary dups for x->24fps) if we are talking about purism, or Tdecimate for removing 1 dup every 25 frames.

Last edited by Dogway; 18th April 2010 at 18:32.
Dogway is offline   Reply With Quote
Old 19th April 2010, 09:09   #11  |  Link
bololo
Registered User
 
Join Date: Aug 2007
Posts: 25
I updated the final script into the first posting for everyone who may suffer similar problems.
Its maybe not perfect, but the best i can afford and compared to the source i am satisfied with the result.

Thank you everybody for reading/helping
bololo is offline   Reply With Quote
Old 23rd June 2010, 03:25   #12  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 949
I like restoring old anime so I tried your source, this is what I got, only left a spot remover, and the 25->24fps thing, with some fine tweaking, but I think now it is more viewable. There isnt a better quality release of this anywhere?

1.6Mb
http://www.sendspace.com/file/s6zfak
Dogway is offline   Reply With Quote
Reply

Tags
ancient, anime, avisynth, improve, repair

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:44.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2017, vBulletin Solutions Inc.