View Full Version : AnimeIVTC() - All-in-one solution for interlacing and blending - v2.00 [2010-01-07]
thetoof
1st June 2008, 09:25
Guide and v2 here. http://www.sendspace.com/file/jb3c3k Requirements package prepared by Overdrive80 - http://www.mediafire.com/?nydyyqqyqhq.
This function can also work with any other hard telecined, hybrid or field-blended source.
The thread was originally created after encountering multiple interlacing and blending related issues that were documented here and there, or simply too rare to be documented, but never all in the same place. Its purpose was to gather as many samples as possible and to converge discussions about them to eventually create a function that could deal with all the issues in an optimal and easy to use fashion. Pretentious? Maybe. Useful? Yes imo.
It is not as versatile as doing everything externally, as the goal is to make the ivtc/deinterlacing/deblending/decimation process as simple as possible, while still aiming at the best possible quality. Filter choices and available parameters are therefore arbitrary, but feel free to object and mention what you think is missing or wrong.
So, have fun, filter and post!
I'll leave the following for now, but it's meant to be replaced by a guide I've been promising to write for many many months...
# Particularities of anime:
- While a film is shot at 24 frames per second (fps), anime is animated at 24fps so there is not necessarily motion on every frame.
- When there is not a lot of movement, it can be displayed at lower framerates like 8 or 12 fps with duplicate(s) of every frame to maintain a constant framerate of 24fps.
- To create the illusion of faster movement, different parts of the image can move at different framerates. In this situation, the image is divided into 2 parts and there are many possible combinations of "intra-frame variable framerate". This is not constant throughout the episode/movie since it changes depending on the amount of motion to be displayed.
- CG animation at 30 fps is sometimes used in anime, so you can also have sequences with movement on every frame without any interlacing nor blends.
- The credits can be truly interlaced to make them run faster without being juddery and unreadable, thus leaving more room for the show.
- The credits can also be at the full progressive framerate on top of the telecined background.
# Basic concepts:
Soft telecine - the stream is encoded at 24 fps and the pulldown is applied during playback.
Hard telecine - your source was telecined before being encoded on the DVD (or before airing).
Double hard telecine - your source has at least one of the "intra-frame variable framerate" situations and the telecining was applied separately on each part of the frame, so the pattern is not constant and many frames are interlaced.
Field blended norm-conversion - Instead of going back to 24fps (film rate), the video streams are directly converted from NTSC (29.97fps) to PAL (25fps) or vice versa, creating ugly fieldblending (looks like DHT when inspecting a frame).
Hybrid - mix of 24t (24 fps displayed at 30 through telecining) and 30p (progressive movement on every frame)
Truly interlaced - each frame contains half the information of two frames, which means that you can bob it to 60p and see movement on every single frame, without any interlacing or blending.
Progressive - No interlacing whatsoever at the full framerate.
3:2 pattern - This pattern repeats itself from the very beginning to the very end of your clip: 3 progressive frames followed by 2 interlaced ones.
VFR - Variable Frame Rate - The sections of the clip run at different framerates, thus allowing to have less frames for the same movement. The duplicates are removed and played during the same amount of time as if there was the original amount of frames.
Lossless rendering pass - Save the file as uncompressed YV12 or Lagarith to apply the script only once and make subsequent filtering/encoding faster. It takes a lot of disk space: around 5GB for a 22 minutes clip @ 23.976fps with Lagarith and 20GB with uncompressed YV12.
# Examples:
Double Hard Telecine - At first, your source may look like a typical Hard Telecined one (http://img140.imageshack.us/img140/5674/ht1224lqro7.jpg), but after a more thorough inspection, you'll see that it's actually a DHT one: same source, different high motion scene (http://img207.imageshack.us/img207/3659/dhtlqtr2.jpg).
Interlaced on top of telecined (can be hard or double hard) - In this case, it was a hard telecined source. Image (http://img520.imageshack.us/img520/6759/24t30ilqrw3.jpg)
Obviously, since there's no pattern in DHT and interlacing on every frame with pure interlaced material, regular IVTC will output blends and jerkiness.
- What it does:
- High quality adaptative field matching for hard telecine
- Bob, remove the blends and decimate back to the desired framerate for DHT/field-blended
- Creating a VFR clip for hybrid sources
- Bob the interlaced credits, blend-deinterlacing the background while doing minimal damage on the progressive credits, convert their framerate to match the episode's and splice them with it OR leave them @ 30p to create a VFR clip
- Very good combing removal and anti-aliasing functions (can be called externally as eediaa() daa() maa() or sharpaamcmod())
No AA (http://img88.imageshack.us/img88/1294/aliaseddy2.jpg) // AA (http://img153.imageshack.us/img153/2540/antialiasingqb9.jpg)
thetoof
1st June 2008, 09:31
AnimeIVTC() v1.03 is too long to fit in a single post... so for now I'll leave this empty in case I need it someday.
Ah "IT" is released into the wild!! I will check it out more in the morning, but looks like it will have to be added to the arsenal!!
HymnToLife
1st June 2008, 12:54
Hmm, I have trouble getting my hands on VinverseD, and it's not in your Requirements archive. Care to post it here? (Tritical's Vinverse is not either, btw, but this one is easy to find)
EDIT : Got it (http://forum.doom9.org/showpost.php?p=841641). However, is there a reason why both are used? From what I can gather, Tritical's is just a rewrite of Didée's as a plugin.
EDIT 2 : anyway, many many thanks for a great function, it will make my life much easier from now on :D
thetoof
1st June 2008, 17:15
Yup, forgot to add vinverse... but as you said it's easy to find the plugin. The vinverse script is actually where vinverse was originally thought, but I recommend getting the actual plugin by tritical instead.
VinverseD is a function included in mcbob, so it is part of requirement package. I made it possible to use both because vinverseD is stronger (and slower), so it might be useful for very tricky sources.
Zarxrax
1st June 2008, 17:26
Interesting. I'll test this out on some various sources when I get a chance.
MADAJ
2nd June 2008, 06:20
http://img87.imageshack.us/img87/3492/11um0.jpg
How can I solve this problem?
thetoof
2nd June 2008, 07:48
I guess you used mode=2 or 4 with decimate=5 or check=7 since those settings are the only ones using requestlinear... but could you post your script and tell the version of TIVTC and mrestore you're using? Try replacing them with the ones included in the "requirements.7z" file I uploaded. It may solve your issue.
manono
2nd June 2008, 08:35
Yeah, that error is usually caused when using an old version of TIVTC. Update it and try again.
HymnToLife
2nd June 2008, 17:49
Yep, I got the same thing at first, but replaced all my plugins with the ones provided in Requirements.7z and everything's working fine. Really great stuff btw, my Sky Girls DVDs still needed quite a bit of denoisig/sharpening afterwards, but this completely eliminated the combind and edge flickering. Thanks again for a very n00b-friendly script =)
MADAJ
2nd June 2008, 18:26
Try replacing them with the ones included in the "requirements.7z" file I uploaded. It may solve your issue.
It does. :)
thanks a lot.
elguaxo
2nd June 2008, 18:50
thanks
Nightshiver
2nd June 2008, 23:00
How do you go about splicing in credits to the end/beginning of an anime series?
thetoof
3rd June 2008, 00:02
If you want to use a creditless version of the op/ed, use
a=file + processing
b=file + processing
c= ...
...
a+b+c+....
and if you want to process them to have them @ 23.976fps with no interlacing or jerks, use
animeivtc(mode=3, omode=1 [other settings]) #would have been mode=4 if it was a double hard telecine, but since I know your source, I can assure you it's a hard telecined one
Also, about the other question you asked me by PM, use the guide to identify your source (a few things were not posted to reduce the size of the first post). If you still can't, post a sample.
Nightshiver
3rd June 2008, 00:22
Do I add animeivtc(mode=3, omode=1 [other settings]) to my entire script? If so, should I still have/use TFM + Tdecimate at the beginning? I also presume that there is a comma after omode=1 and that the "other settings" means other settings I might choose in animeivtc?
EDIT: After just putting in (mode=3, omode=1), vdubmod gives me the error that I must specify a pureint function from 1 to 7. I looked at it and have no clue as how to work it. For example, the first function is 1 : i1 + e1. Do I make the i=0 all the time? How do I know which number to put in, such as do I use pureint=1 or =2 or =3 etc. More info: the start frame of the credits is 39594 and the end frame is 41539.
HymnToLife
3rd June 2008, 00:45
So far, I've only been able to get my hands on pure hard telecined stuff (i.e. mode=1) and all I had to do was
DGDecode_mpeg2source("blah.d2v")
AnimeIVTC(mode=1, aa=2)
And that's that, I got a nice 23.976 clip with all the combing/blends/etc. removed. Also, I think we need you to post your whole script in order to troubleshoot it, not just a part of it ;)
Nightshiver
3rd June 2008, 00:54
You don't need my entire script as I"m only asking about splicing in credits, not help on building an entire script.
HymnToLife
3rd June 2008, 00:59
Hmm, then I'm not sure I understand what you mean by "splicing in credits". Do you mean you have a creditless version of the op/end that you want to insert instead of the normal version that is in your episodes?
Nightshiver
3rd June 2008, 01:20
No. read up on the thread I made about this: http://forum.doom9.org/showthread.php?t=137538
I want the entire episode AND the credits. If you read in the thread, the problem was that the credits are pure interlaced while the rest of the episode is not.
HymnToLife
3rd June 2008, 01:38
Oh, right, I missed that pureint stuff. Well, the value you have to use for it depends on where the pure interlaced parts are located in your clip. For example, "1 : i1 + e1" means that you must use pureint=1 if you have a pure interlaced section followed by an IVTC section. In your case, you have two pure interlaced sections, so you would use 2, 3, 6 or 7 depending on whether you have IVTC section before the op and/or after the ed. For example, if you have an IVTC section before the op and after the ed, the pattern of the whole clip is
IVTC (before op), interlaced (op), IVTC (main), interlaced (ed), IVTC (after ed)
so you would use pureint=7 (e1 + i1 + e2 + i2 + e3). On the other end, if the op begins right at the start of the episode, and the ed ends right at the end, you would use pureint=2.
EDIT : of course, then you must use [i|e][start|end][1|2|3] to specify the frames where the different sections start/end.
Nightshiver
3rd June 2008, 01:46
Thanks for your help, but I think I might need thetoof to help a little more. Using pureint=2 means
2 : i1 + e1 + i2
I still don't understand this. I gave the frames for the ending and I don't know where to put them. What frame would I use for the e1 value since I only want to splice in the op and ed.
For instance, how would I go about using start/end i.e. istart/iend? Would it be something like:
i1(0,end frame of the op)
e1(i have no idea what to put)
i2(39594,41539)
HymnToLife
3rd June 2008, 02:13
No, no, you got it wrong. Those i1, e1 and i2 are just schematic representations to help you figure out which pureint value you need to use depending on your source, they're not functions or parameters. If I understand the guide correctly, in your case, it would look like :
AnimeIVTC(mode=3, omode=1, pureint=2, istart1=0, iend1=END_FRAME_OF_OP, estart1=END_FRAME_OF_OP+1, eend1=39593, istart2=39594, iend2=41539)
As some of the parameters seem redundant, maybe they can be omitted, but I think that's the general idea of what your function should look like. thetoof will surely be able to give further details.
Nightshiver
3rd June 2008, 02:22
The end frame of op is 2705. But when I plugged everything in, vdubmod gave me the error "video framerate doesn't match".
HymnToLife
3rd June 2008, 15:47
This is precisely why I asked you to post your whole script. This error happens when you try to splice together clips that have different framerates. How are we supposed to know where the error is if we don't know what you're doing?
Nightshiver
3rd June 2008, 16:39
How in the world is posting my script going to help? Used MVdegrain3
TFM
TDecimate
aaa()
and LSF
I do not see how in the world this will help you in anyway. I know there are different frame rates, thats what I'm trying to fix! The credits are pure interlaced while the rest of the encode has been IVTC'ed to 23.976 fps.
HymnToLife
3rd June 2008, 16:54
I think that's not how you're supposed to use AnimeIVTC(). From what I can gather, you just give it the whole clip (with the pure interlaced and the TC'ed parts) in input, and then it does it's magic and give you the fixed clip in output.
The guide says :
omode : Determines the output framerate
* 1 : Converts the interlaced section(s) to 23.976 to maintain a Constant Frame Rate
So that's that, when you use AnimeIVTC(mode=3, omode=1), it will convert the interlaced parts to 23.976 fps for you, then you'll have your whole clip with a constant frame rate in output. Otherwise, you'll have to go VFR and that can be a bit tricky.
Nightshiver
3rd June 2008, 17:37
Yeah, I get that. When I used animeivtc, I took out TFM and Tdecimate that way animeivtc could do the ivtc. In fact, I emptied the entire script and only used animeivtc but I still got the error.
Basically, my script right now is:
MPEG2Source("E:\nge.d2v")
AnimeIVTC(mode=3, omode=1, pureint=2, istart1=0, iend1=2706, estart1=2707, eend1=39593, istart2=39594, iend2=41539)
That's it. The reason for this is because I don't want anything else interfering with the filter since it's been giving me errors, so the problem still has not been solved.
OvejaNegra
6th June 2008, 01:32
another issue with trigun:
mpeg2source("d:\trig\ep23.d2v", idct=0)
animeivtc (mode=7,aa=1,pass=1,omode=3,pureint=5,estart1=0,eend1=959,istart1=40873,iend1=43343)
if i understand correctly: i have IVTC credits from 0 to 959 and interlaced credits (for better scrolling) from 40873 to 43343. I want the end credits bobed (59.94) but i have this error:
Evaluate: operands of == and != must be comparable
(bunch of characters like @and -), line 66
Yes, i'm using a clean installation of avs and all the plugins from the package. my DGDdecode is up to date.
Sorry for the english.
egrimisu
6th June 2008, 18:15
Is this suposed to work this slow : 1frame at 3-4secondc on e6850 3.0ghz ?
Nice job
egrimisu, it depends on what settings you are using. If you post 'em, we can tell you if something is wrong or not.
martino
7th June 2008, 13:10
I just looked a bit at the code, and wouldn't it be slightly faster to replace the BlankClips with NOP? Or are the BlankClips there for a specific reason, that they need to be processed?
elguaxo
11th June 2008, 19:02
My first try at AnimeIVTC and it looks good! :)
You should include SangNom (http://avisynth.org/mediawiki/SangNom) in the Requirements pack.
:thanks:
thetoof
12th June 2008, 06:42
so the problem still has not been solved.
The following may answer your question. If it doesn't, post again.
- For a CFR clip @ 23,976fps with 24t + 30i, use mode 3 or 4 (in your case, it seems like a mode=3) and omode=1
- Get the frame numbers with the various "check=x"
- If you don't understand clearly what I mean with my examples for pureint=x in the guide, please tell me what way you think would be better
animeivtc(mode=7,aa=1,pass=1,omode=3,pureint=5,estart1=0,eend1=959,istart1=40873,iend1=43343)
Usage: Do a lossless rendering pass of your clip after applying all the other filters you want, load it as avisource("yourfile.avi").animeivtc(7,[other settings if you want]) and follow the guide here.
If you want to process 24t + 30i, use mode 3 for hard telecined and 4 for double hard telecined, not 7.
Is this suposed to work this slow : 1frame at 3-4secondc on e6850 3.0ghz ?
The defaults are aimed towards high quality ivtc, so if it's too slow for you, disable aa and use a lower precision (not recommended at all) However, the speed your talking about is freaking slow... try using a high setmemorymax(). How much RAM do you have?
I just looked a bit at the code, and wouldn't it be slightly faster to replace the BlankClips with NOP? Or are the BlankClips there for a specific reason, that they need to be processed?
Would the speed gain be truly noticeable? and... I'm not sure that they are even processed when the conditional call results in using other functions. Also, for a few reasons, I used blankclip + subtitle to throw error messages instead of assert, so they are somewhat needed.
You should include SangNom in the Requirements pack.
+
Vinverse is not either, btw, but this one is easy to find
done
General things:
- New version of the function posted (syntax errors correction for mode=7)
- There will be some improvements of the vfr decimation when it's aimed towards compressibility improvements, because the current method tends to introduce jerks.
thetoof
12th June 2008, 17:28
@ Nightshiver
I read a bit more your posts to figure out the settings you need to ivtc nge (i.e. you don't need anything else for this). It would look like this for super duper quality with pureint=5:
animeivtc(3,omode=1,pureint=5,aa=x,estart1=0,eend1=39593,istart1=39594,iend1=41539,overlap=6,search=3,pel=4)
The frame numbers are wrong if you took them from the unprocessed clip, you need to get them with check=3 for the interlaced credits (would be check=1 for omode=2 or 3) and check=2 for the episode
To know what to use for pureint:
1 = interlaced credits + telecined episode
2 = interlaced credits + telecined episode + interlaced credits
etc
The fact that you have a section with credits doesn't mean they are interlaced. You need to check frame by frame for a few frames to confirm that they have interlacing on every frame. If they are static or if they follow the same telecining patter as the animation, you musn't consider them as interlaced (i.e. they are telecined).
istartx, iendx, estartx and eendx are used to give the frame number where each section starts and ends, where x is the same as ix and ex (given in the guide to know which pureint to use)
SPiKA
13th June 2008, 22:41
I'm getting this error...
http://img515.imageshack.us/img515/7030/asdvi7.gif
jeffy
13th June 2008, 23:58
@SPiKA:
Just a guess, an outdated version of TIVTC.dll. Sorry if I am wrong.
SPiKA
14th June 2008, 00:04
@SPiKA:
Just a guess, an outdated version of TIVTC.dll. Sorry if I am wrong.
Nopes... I have the latest version.
Guest
14th June 2008, 00:09
@thetoof
You are violating GPL by distributing DLLs without the source code. Please correct the situation immediately for Dup. Thank you.
Leak
14th June 2008, 17:50
@thetoof
You are violating GPL by distributing DLLs without the source code. Please correct the situation immediately for Dup. Thank you.
Don - the GPL doesn't mandate that you absolutely have to distribute the source alongside any binaries, only that you make the source code available upon request.
Of course, putting a download link for the source next to the downloads for binaries (or putting the source into the archive itself alongside the binary) is the easiest way to go, but it's not the only valid one...
np: Autechre - Garbagemx36 (Garbage)
Guest
14th June 2008, 23:08
I know the GPL. He has to at least include an offer of the source with the distribution. But he has only the raw DLL, which is a big no-no.
@thetoof
Has this violation been rectified? Thank you.
roozhou
15th June 2008, 00:03
@thetoof
It works great with double hard telecined materials though it is quite slow on my X2 1.8G (~0.3fps).
But which mode should i use to deal with 30p credits rolling on telecined background?
thetoof
15th June 2008, 14:54
@ SPiKA
Did you copy everything from the requirements archive in your "plugins" folder, including mrestore.avsi? Also, make sure you have only one copy of every function in it. If it doesn't help, I don't have the slightest idea of what could be causing it.
@ roozhou
Never seen that before. Could you give me a sample so I can run some tests? Mode=3 or 4 & omode=2 should do the trick, but I may not look good because the credits are progressive... About the speed, it kinda weird because I get 1.32fps with animeivtc(mode=2, aa=3,killcomb=2) with 30-40% CPU usage (so 60-80% for a Dual-core) and it goes down to 0.5fps with 50% CPU usage (100% for Dual-core) with killcomb=0 (disabled). Does anyone knows why??
@ neuron2
Uptading the dl links now, will be done in a short while.
Guest
15th June 2008, 15:37
Updating the dl links now, will be done in a short while. Thank you very much!
roozhou
15th June 2008, 23:48
30p+telecine sample
http://www.mediafire.com/?hxhlly8jm2y
Akatsuker
16th June 2008, 00:36
It's a very good job.
thetoof
17th June 2008, 06:23
For now, the solution I can think of to deal with progressive credits @ 30fps on telecined background is:
- Blend deinterlacing of the background with minimal damage on the credits
merge(source.nnedi(field=1),source.nnedi(field=0))
I should add it to the function in the next days, but if someone has a better idea in the meantime, I'm eager to know!
TheRyuu
17th June 2008, 06:52
For now, the solution I can think of to deal with progressive credits @ 30fps on telecined background is:
- Blend deinterlacing of the background with minimal damage on the credits
merge(source.nnedi(field=1),source.nnedi(field=0))
I should add it to the function in the next days, but if someone has a better idea in the meantime, I'm eager to know!
I don't think blending would be the best option.
If anything, normal nnedi would be better I think.
thetoof
17th June 2008, 08:21
The reason why I used merge was to avoid edge flickering in the credits:
source: 1 (http://img512.imageshack.us/img512/2122/src0000tz9.jpg) / 2 (http://img525.imageshack.us/img525/747/src0001al6.jpg) / 3 (http://img443.imageshack.us/img443/8169/src0002fq7.jpg)
me: 1 (http://img84.imageshack.us/img84/8175/me0000kd8.jpg) / 2 (http://img408.imageshack.us/img408/5506/me0001xh1.jpg) / 3 (http://img503.imageshack.us/img503/5236/me0002ch2.jpg)
nnedi(): 1 (http://img151.imageshack.us/img151/2204/y0000as6.jpg) / 2 (http://img503.imageshack.us/img503/5193/y0001hw0.jpg) / 3 (http://img261.imageshack.us/img261/4920/y0002lg0.jpg)
I don't like blending either... but heh
Something nice would be to take the edges from the source and overlay them on the nnedi(), but I haven't found a way to avoid putting back the combing by doing so.
TheRyuu
17th June 2008, 16:01
The reason why I used merge was to avoid edge flickering in the credits:
source: 1 (http://img512.imageshack.us/img512/2122/src0000tz9.jpg) / 2 (http://img525.imageshack.us/img525/747/src0001al6.jpg) / 3 (http://img443.imageshack.us/img443/8169/src0002fq7.jpg)
me: 1 (http://img84.imageshack.us/img84/8175/me0000kd8.jpg) / 2 (http://img408.imageshack.us/img408/5506/me0001xh1.jpg) / 3 (http://img503.imageshack.us/img503/5236/me0002ch2.jpg)
nnedi(): 1 (http://img151.imageshack.us/img151/2204/y0000as6.jpg) / 2 (http://img503.imageshack.us/img503/5193/y0001hw0.jpg) / 3 (http://img261.imageshack.us/img261/4920/y0002lg0.jpg)
I don't like blending either... but heh
Something nice would be to take the edges from the source and overlay them on the nnedi(), but I haven't found a way to avoid putting back the combing by doing so.
If you're going to blend, try smart bobbing it then.
b=last
interp = b.nnedi(field=-2)
tdeint(mode=2,edeint=interp)
thetoof
17th June 2008, 16:29
I don't see any visual difference (if you do, please post screenshots) and here's the speed I get:
tdeint(2,edeint=nnedi(-2)) = 1,32 fps
merge(nnedi(1),nnedi(0)) = 4,39 fps
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.