changeandy
1st January 2007, 00:50
Hi I just spent about 2 months tweaking this deinterlacing algorithm, and it turned out quite nicely (I think), so I thought I'd share.
It may be a bit slow, but it manages stuff like window blind flicker and keeping progressive frames progressive quite well. It outputs at double the original framerate, so you can also use it to create SloMo footage.
Issues:
- It seems to have some problems with YV12 footage, so you might have to convert to YUY2 first.
- Frames with very little motion are interpreted as progressive, so this algorithm will put out two identical frames. Shouldn't matter much though, as you probably will be reducing the framerate, or, if you are using it for SloMo the frames will be high motion anyway.
- Speed. I'm just a script kid, not a real coder. I just combined what other people have written. Sorry :-(
Well, so without any further ado here it is, hope you like it:
IntFootage=avisource("myvideo.avi")
doubled = IntFootage.separatefields().DoubleWeave()
# What we base our interlaced/progressive decision on
smoothie = IntFootage.SmoothDeinterlace(tff=false, doublerate=true,lacethresh=0)
# Deinterlaces with very little flicker for pure interlaced, but does not handle progressive frames that well.
#! You might have to change the tff parameter
TreatAsCombed = IntFootage.tdeint(mode=1,cthresh=2,tryweave=true,edeint=smoothie)
# This replaces the combed parts with the corresponding parts of smoothie. Cthresh is at very low tolerance.
TreatAs1Frame = IntFootage.tdeint(mode=1,cthresh=10,tryweave=true,edeint=smoothie)
# Same as TreatAsCombed, but cthresh is set so that it uses as much of the original scanlines as possible
ConditionalFilter(doubled, TreatAsCombed, TreatAs1Frame, "IsCombed(11)", "equals", "true", show=false)
# Chooses the appropriate proc. method, whether the frame shoud be treated as combed or progressive
FieldDeinterlace(map =false, blend=true, dthreshold=3)
# Removes most of the remaining combing atifacts
msharpen(threshold=8,strength=23,mask=false,highq=false)
# Sharpens the image slightly after processing. Not strictly part of the deinterlacing, but I like the results
selectevery(2,0)
# Use this if you want to keep the original framerate. If you want to convert NTSC video (29.97i) to look like film (23.976p) use selectevery(10,0,2,5,7). For SloMo use assumefps(*your project's framerate*) instead.
Well that's it, I hope I assembled something useful to you here. If you use it please post where you find it to work well, and where it causes problems, so people can decide if this is useful for them.
Thanx go out to all the coders who created and contributed to AviSynth, without whom this script kid's contribution would have been impossible. Thank you.
Changeandy
It may be a bit slow, but it manages stuff like window blind flicker and keeping progressive frames progressive quite well. It outputs at double the original framerate, so you can also use it to create SloMo footage.
Issues:
- It seems to have some problems with YV12 footage, so you might have to convert to YUY2 first.
- Frames with very little motion are interpreted as progressive, so this algorithm will put out two identical frames. Shouldn't matter much though, as you probably will be reducing the framerate, or, if you are using it for SloMo the frames will be high motion anyway.
- Speed. I'm just a script kid, not a real coder. I just combined what other people have written. Sorry :-(
Well, so without any further ado here it is, hope you like it:
IntFootage=avisource("myvideo.avi")
doubled = IntFootage.separatefields().DoubleWeave()
# What we base our interlaced/progressive decision on
smoothie = IntFootage.SmoothDeinterlace(tff=false, doublerate=true,lacethresh=0)
# Deinterlaces with very little flicker for pure interlaced, but does not handle progressive frames that well.
#! You might have to change the tff parameter
TreatAsCombed = IntFootage.tdeint(mode=1,cthresh=2,tryweave=true,edeint=smoothie)
# This replaces the combed parts with the corresponding parts of smoothie. Cthresh is at very low tolerance.
TreatAs1Frame = IntFootage.tdeint(mode=1,cthresh=10,tryweave=true,edeint=smoothie)
# Same as TreatAsCombed, but cthresh is set so that it uses as much of the original scanlines as possible
ConditionalFilter(doubled, TreatAsCombed, TreatAs1Frame, "IsCombed(11)", "equals", "true", show=false)
# Chooses the appropriate proc. method, whether the frame shoud be treated as combed or progressive
FieldDeinterlace(map =false, blend=true, dthreshold=3)
# Removes most of the remaining combing atifacts
msharpen(threshold=8,strength=23,mask=false,highq=false)
# Sharpens the image slightly after processing. Not strictly part of the deinterlacing, but I like the results
selectevery(2,0)
# Use this if you want to keep the original framerate. If you want to convert NTSC video (29.97i) to look like film (23.976p) use selectevery(10,0,2,5,7). For SloMo use assumefps(*your project's framerate*) instead.
Well that's it, I hope I assembled something useful to you here. If you use it please post where you find it to work well, and where it causes problems, so people can decide if this is useful for them.
Thanx go out to all the coders who created and contributed to AviSynth, without whom this script kid's contribution would have been impossible. Thank you.
Changeandy