AnimeIVTC
(→Interlaced or progressive credits) |
(→Interlaced or progressive credits) |
||
Line 149: | Line 149: | ||
<var>credconv</var> : Determines how the credits will be converted for '''''omode=1''''''''' | <var>credconv</var> : Determines how the credits will be converted for '''''omode=1''''''''' | ||
** "mocomp" : Use motion-compensation. Use when you have low motion backgrounds to get a blend free and stable clip. | ** "mocomp" : Use motion-compensation. Use when you have low motion backgrounds to get a blend free and stable clip. | ||
− | ** "blend" : Blend frames together to reduce framerate(ugly and fast, but can lead to less disturbing artifacts when you have a high motion background)'''''' | + | ** "blend" : Blend frames together to reduce framerate (ugly and fast, but can lead to less disturbing artifacts when you have a high motion background)'''''' |
** "Drop"<span style="color:red">*</span> : Drop frames to reduce framerate creds into 24t (ugly and fast, will lead to stuttery motion)'''''' | ** "Drop"<span style="color:red">*</span> : Drop frames to reduce framerate creds into 24t (ugly and fast, will lead to stuttery motion)'''''' | ||
: <span style="color:red">*</span> in mod ver. only. | : <span style="color:red">*</span> in mod ver. only. |
Revision as of 15:41, 30 July 2015
Abstract | |
---|---|
Author | thetoof |
Version | 2.00 |
Download | [Doom9 Thread (original)][Doom9 Thread (mod)] |
Category | IVTC & Decimation |
Requirements | |
License | [CreativeCommons BY-SA 3.0] |
Discussion |
Contents |
Abstract
Author: thetoof
Version: 2.00
Discussion: forum.doom9.org
Category: IVTC & Decimation
Requirements:
Put all the .dll/.avsi in the "plugins" folder of avisynth. You can get them all here.
- TIVTC, TDeint and TMM by tritical link
- nnEDI2 by tritical link
- nnEDI3* by tritical link or for avs 2.6 link
- EEDI2 by tritical, multithreaded version by foxyshadis link
- yadifmod by tritical link
- TGMCmod by thetoof (in 7z archive), original version by Didée here - link
- QTGMC* by -Vit- - link
- MVTools2 by Fizick link
- RemoveGrain and Repair by kassandro link
- MaskTools by Manao link
- MaskTools2 by Manao link
- Vinverse by tritical (original script by Didée) link
- MedianBlur by tsp [1]
- srestore by MOmonster link
- Average by mg262 link
- ReduceFlicker by kassandro link
- SangNom by MarcFD link
- Toon by Soulhunter (original script by mf, speedups by Didée) link
- Lsfmod by LaTo link, original version by Didée here link
- aWarpSharp and Toon rewrites by SEt link
- Microsoft Visual C link
- AvsRecursion by kassandro (put in your system32 folder... or something else if you're not running with XP 32) link
- and of course, AnimeIVTC by thetoof ;-)
- * required for mod ver..
I) About anime telecining
- 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, but after a more thorough inspection, you'll see that it's actually a DHT one: same source, different high motion scene. Interlaced on top of telecined (can be hard or double hard) - In this case, it was a hard telecined source. Image Obviously, since there's no pattern in DHT and interlacing on every frame with pure interlaced material, regular IVTC will output blends and jerkiness.
Apply TComb before AnimeIVTC if you need to correct dotcrawl.
It is NOT* recommended to use animeivtc with multithreading and/or calling it multiple times in a script. If you want to multithread it, see the examples example scripts below.
- * can be done in mention cases here.
II) Function descriptions
- General settings
- Interlaced or progressive credits
- Mode=1 (Hard telecined)
- Mode=2 (Field-blended)
- Mode=3 (Double hard telecined)
- hybrid Mode=4 (Hybrid)
AnimeIVTC
(clip i, int "mode", int "aa", int "precision", int "killcomb", int "cache", bool "ifade" , bool "chrfix" , bool "blend" , bool "normconv" , int "pattern" , int "pass", bool "rendering" , int "bbob", int "cbob", string "edimode", int "degrain", int "omode" , int "cthresh"* , int "blockx"* , int "blocky"* , int "MI"* , int "tfmm"* , int "pp"* , int "metric"* , int "micmatching"* , int "i1", int "i2", int "e1", int "e2", int "e3", int "p1", int "p2" , bool "dchr"* , bool "palf"* , bool "tcfv1"* , bool "nvfr"* , bool "real30p"* , bool "autoAssuf"* , int "ediandnn"* , bool "o3025cfr"* , int "overlap", int "pel", int "search", bool "nnedi3pel"** , string "credconv" , bool "mode22"* , clip "ediext"* , string "bob4p"* , clip "extbob"* , string "extbobf"* , bool "yadifrepwithtdeint"* , float "dark", int "thin", int "sharp", int "smooth", bool "stabilize", int "tradius", int "aapel", int "aaov", int "aablk", int "aatype")
- * in mod ver. only.
- ** nnedi2pel in original ver..
General parameters
mode : Required parameter. Defines the function's behavior
- 1 : Hard telecined
- 2 : Field blended
- 3 : Double hard telecine
- 4 : Hybrid
chrfix : Use to correct chroma swap between fields (to find out, apply bob() on your clip and examine the frames. If at some point the chroma of a frame is in the other and vice-versa, the issue is present).
- True
- False (default)
ifade : Detects and corrects interlaced fade-ins. Use for mode=1 or 4 since the clip is bobbed in mode=2 and 3.
- True
- False (default for speed concerns, but enabling it can be safer)
cache : Sets amount of frames to cache for all functions using scriptclip to prevent seeking issues frame order mess-up with temporal filters. Using too much will result in crashing, so use less if you get memory issues.
- 0 to inf. (default=10)
killcomb : Removes any residual combing. Use for mode=1 or 4 since the clip is bobbed in mode=2 and 3.
- 0 : No combing removal (default)
- 1 : Combing removal with vinverse()
- 2 : Slower, but more aggressive combing removal by using mcbob's method
- 3 : Even slower, but better detail preservation and sharpness. Same as aa=3 [daa()]
aa : Antialiasing. None is necessarily better than the others, but one is more adapted to your needs. [Images/aliased.jpg without][Images/anti-aliasing.jpg with]
- -1: Compare by interleaving the different aa options
- 0 : No aa
- 1 : EEDI2() based aa [can be called externally as ediaa()]
- 2 : Average of a spatial interpolations of each fields contra-sharpening [can be called externally as daa()]
- 3 : Edge targeted Sangnom() aa leaving the rest of the frame untouched - watch out for detail loss... if you can spare some additionnal processing time, take a look at aa=4 [can be called externally as maa()]
- 4 : Line darkening, warp sharpening, edge targeted aa, limited sharpening and temporal stabilizing [can be called externally as SharpAAMCmod()]
The following options are meant for aa=4 [SharpAAMCmod()] aatype : Select the filter used for aa
- "Sangnom" (default)
- "EEDI2" (slower, but sometimes has better detail preservation than Sangnom)
dark : Line darkening strength by using Toon
- 0 to 1 (default=0.2)
thin : Higher = thinner lines by using warpsharp
- default = 10
sharp : Post-sharpening strength of LSFmod
- 0 to inf. (default = 150)
smooth : Post-softening strength of LSFmod
- 0 to 100 (default = 100)
- -1 = The function will (try to) autocalculate a good value
stabilize : Edge stabilizing through motion compensation with MDegrain's temporal averaging - use if the edges are unstable (trembling, flickering...) or as a edge-directed smart soothe().
- True
- False (default)
tradius : Temporal radius (# of frames*2 1) of the stabilization.
- 0 to 3 (default=2)
aapel : Supersampling factor for motion vector calculations when using stabilize=true. Higner = better, but slower
- 1, 2 or 4 (default=1)
aablk : Size of the blocks for motion vector calculations when using stabilize=true. Larger blocks are less sensitive to noise, are faster, but also less accurate.
- 4, 8 or 16 (default=8 for SD and 16 for HD)
aaov : Overlap of the blocks for motion vector calculation when using stabilize=true. Higner = better, but slower
- Must be even and up to half aablk (default=4 for SD and 8 for HD)
Interlaced or progressive credits
i1/i2/p1/p2/e1/e2/e3 : Give the frame numbers to the function so that each section is processed correctly. Use your source's frame numbers. You do not have to specify all of them. Example - a bit of the telecined episode interlaced opening credits episode progressive ending credits next episode preview. Use e1=w,i1=x,e2=y,p1=z,e3=a.
- i1 Last frame of the 1st interlaced section of the clip
- i2 Last frame of the 2nd interlaced section of the clip
- p1 Last frame of the 1st progressive section of the clip
- p2 Last frame of the 2nd progressive section of the clip
- e1 Last frame of the 1st telecined/double hard telecined/field blended/hybrid section of the clip
- e2 Last frame of the 2nd telecined/double hard telecined/field blended/hybrid section of the clip
- e3 Last frame of the 3rd telecined/double hard telecined/field blended/hybrid section of the clip
omode : Determines the output framerate
- 1 : Converts the credits to the framerate of the episode to maintain a Constant Frame Rate. Mandatory for norm conversions.
- 2 : Credits are maintained at 29.97 fps (half their full temporal resolution) to create a Variable Frame Rate clip. Intended for mkv files.
credconv : Determines how the credits will be converted for omode=1''''
- "mocomp" : Use motion-compensation. Use when you have low motion backgrounds to get a blend free and stable clip.
- "blend" : Blend frames together to reduce framerate (ugly and fast, but can lead to less disturbing artifacts when you have a high motion background)'
- "Drop"* : Drop frames to reduce framerate creds into 24t (ugly and fast, will lead to stuttery motion)'
- * in mod ver. only.
overlap : Overlap of the blocks for motion vector calculation. Higner = better, but slower. Use for "mocomp".
- 0, 2 or 4 for SD (default=4)
- 0, 2, 4, 6 or 8 for HD (default=8)
pel : Supersampling factor for motion vector calculation. Higner = better, but slower. Use for "mocomp".
- 1, 2 or 4 (default=2)
search : Have fun testing. 4 and 5 are usually better than 2 for roughly the same speed. Use for "mocomp".
- 2 (Logarithmic search, also named Diamond Search)
- 3 (Exhaustive search) - slowest, but best results SAD-wise (basically the mo-comp is done by calculating the sum of absolute differences between blocks to determine if it is the same element moving or a different one) Attempt at lame joke: no, we're not talking about this here... SAD
- 4 (Hexagon search - similar to x264) (default)
- 5 (Uneven Multi Hexagon search - similar to x264)
nnedi2pel : Use nnEDI2 for interpolation. True = usually better. Use for "mocomp".
- true
- false (default)
pass : Creating a VFR clip requires two passes. The file you must use for your final encode/subsequent filtering must be the one generated by pass=2. Use for omode=2.
- 1 : Open with vdub, file-run video analysis pass, wait until the end, close vdub OR do a rendering pass (saving the filtered clip in a lossless (i.e. with Lagarith or HuffYUV) avi file for further use to avoid computing the same thing twice - once for analysis and another to decimate) (default)
- 2 : Reload the same script with pass=2. Use the new avi file as source if you did a rendering pass. After all subsequent filtering, encode. Then, take the "timecode.txt" file and add it as the timecode for the video stream in mkvmerge.
rendering : If you did a rendering pass , this will only be VFR decimation based on the files written by pass=1. Use for omode=2 and pass=2.
- True (you did a rendering pass and only want to decimate in pass=2)
- False (you did not create any intermediate file) (default)
cbob : Higher = slower, but more precise... Here, it's almost only about quality vs speed. Use for interlaced credits.
- 0 : Fastest, TDeint alone
- 1 : Better (TDeint nnedi2 for interpolation)
- 2 : Even better (TDeint nnedi2 motion mask)
- 3 : Alternate (Yadifmod nnedi2 for interpolation)
- 4 : Most stable bobber around - TGMC. Slow. (default)
edimode : Tells which filter to use for spatial interpolation with cbob=4. The "best" one depends on your source. Use for interlaced credits.
- "yadif"
- "eedi2"
- "nnedi2" (default)
degrain : Temporal radius (# of frames to use * 2 1) for the final degraining step with cbob=4. Higher = slower more noise removal more stable. Use for interlaced credits.
- 1 (default)
- 2
- 3
Hard telecine (mode=1)
precision : Higher = slower, but more precise... Here, it's only about quality vs speed.
- 0 : Fastest, tfm only
- 1 : Better (uses Tdeint to deinterlace)
- 2 : Even better (Tdeint nnedi2 for interpolation)
- 3 : Optimal (Tdeint nned2i motion mask) (default)
blend : If you have a case of blend telecine, or blend-deinterlacing of telecined footage. 3:2 pattern - 3 clear, 2 blended. Weight must be 50/50.
- True
- False (default)
Field blended (mode=2)
bbob : Higher = slower, but more precise... Here, it's almost only about quality vs speed. Mo-comp is not recommended for blended material, but I left in case you have stability issues with the other bobbers.
- 0 : Fastest, TDeint alone
- 1 : Better (TDeint nnedi2 for interpolation)
- 2 : Even better (TDeint nnedi2 motion mask)
- 3 : Alternate (Yadifmod nnedi2 for interpolation) (default)
- 4 : Most stable bobber around - TGMC. Slow.
edimode : Tells which filter to use for spatial interpolation with cbob=4. The "best" one depends on your source.
- "yadif"
- "eedi2"
- "nnedi2" (default)
degrain : Temporal radius (# of frames to use * 2 1) for the final degraining step with cbob=4. Higher = slower more noise removal more stable.
- 1 (default)
- 2
- 3
normconv : Set to true if your source was blend-converted from PAL to NTSC or vice-versa.
- True : Change framerate to 25fps if your source is NTSC or to 23.976fps if it's PAL
- False : Keep 25fps if source is PAL and 23.976 if source is NTSC (default)
Double hard telecine (mode=3)
cbob : Higher = slower, but more precise... Here, it's almost only about quality vs speed.
- 0 : Fastest, TDeint alone
- 1 : Better (TDeint nnedi2 for interpolation)
- 2 : Even better (TDeint nnedi2 motion mask)
- 3 : Alternate (Yadifmod nnedi2 for interpolation)
- 4 : Most stable bobber around - TGMC. Slow. (default)
edimode : Tells which filter to use for spatial interpolation with cbob=4. The "best" one depends on your source.
- "yadif"
- "eedi2"
- "nnedi2" (default)
degrain : Temporal radius (# of frames to use * 2 1) for the final degraining step with cbob=4. Higher = slower more noise removal more stable.
- 1 (default)
- 2
- 3
pattern : Tells the function how to decimate to 23.976 fps.
- 0 Safest. Uses TDecimate. (default)
- -1 Compare 1 to 5.
- 1 to 5 If your source has a fixed pattern, finding it with -1 and using the appropriate one will be faster and visually better, but as soon as there's a change, everything will be a mess. Be careful.
Hybrid (mode=4)
precision : Higher = slower, but more precise... Here, it's only about quality vs speed.
- 0 : Fastest, tfm only
- 1 : Better (uses Tdeint to deinterlace)
- 2 : Even better (Tdeint nnedi2 for interpolation)
- 3 : Optimal (Tdeint nned2i motion mask) (default)
omode : Determines the output framerate
- 1 : Converts the 30p sections to 24p by blending frames together to maintain a Constant Frame Rate.
- 2 : 30p sections are maintained at 29.97 fps to create a Variable Frame Rate clip. Intended for mkv files.
pass : Creating a VFR clip requires two passes. Rendering passes are only recommended when you have interlaced or progressive credits or when ifade=true. You will not see the results of killcomb and aa in pass=1. The file you must use for your final encode/subsequent filtering must be the one generated by pass=2. Use for omode=2.
- 1 : Open with vdub, file-run video analysis pass, wait until the end, close vdub OR do a rendering pass (saving the filtered clip in a lossless (i.e. with Lagarith or HuffYUV) avi file for further use to avoid computing the same thing twice - once for analysis and another to decimate) (default)
- 2 : Reload the same script with pass=2. Use the new avi file as source if you did a rendering pass. After all subsequent filtering, encode. Then, take the "timecode.txt" file and add it as the timecode for the video stream in mkvmerge.
rendering : If you did a rendering pass , this will only be VFR decimation based on the files written by pass=1. Use for omode=2 and pass=2.
- True (you did a rendering pass and only want to decimate in pass=2)
- False (you did not create any intermediate file) (default)
III) Examples
AnimeIVTC is quite easy to use... if you have questions after reading this manual, please post in the AnimeIVTC thread. Here is a way to multithread it, but you can use the concept in many different ways (loading from different hard drives outputting to different hard drives and so forth). I only used 3 threads because more was too much for the source HDD, even when writing to 4 different ones. Do NOT use for VFR encodes, where analysis and decimation must be done in one shot.
xxxsource("file.ext") threads = 3 s=AnimeIVTC([settings]) a=s.trim(0,int(framecount(s)/threads)) b=s.trim(int(framecount(s)/threads) 1,int(framecount(s)/threads-1)) c=s.trim(int(framecount(s)/threads-1) 1,0) a #load this script in vdub and save as rendering1, then change a to b and save as rendering2, ideally on a different HDD... etc etc #then, for further processing or encoding, load your different files and splice them, such as: #a=avisource(rendering1 file with path) #b=avisource(rendering2 file with path) a b .....
IV) Revisions
2.00 Released 2010-01-07 by thetoof
- v2 because of the syntax changes
- Compatibility with MVtools2
- Compatibility with srestore for field blended
- New (and better) decimation for dht
- The user will determine the end frames of every sections in case of progressive/interlaced credits and the rest will all be done internally (no need to switch between the checks since it was a pain)
- Handling of the blend-decimation of hybrid sections in omode=1
- More aa and killcomb options
- New parameter to fix chroma swap between fields
- New parameter to fix blend telecine
- New parameter to fix interlaced fade-ins
- The modes are "re-thought" : mode=1 (hard telecine) mode=2 (field blended) mode=3 (double hard telecine) mode=4 (hybrid) At the moment you define a frame # for interlaced or progressive credits, the function adapts itself
- Memory usage decreased for a few modes
- No need to specify the region of your source (done internally) Single parameter added (bool "normconv") to go from one to another
- More accurate external pelclip with nnedi2 for optimal motion vectors calculation
- Rewriting of the function from scratch to prevent memory waste and other issues (I had patched with a few tricks here and there which made it harder to read. It's almost all gone now)
- Maybe a few other things I'll add when I remember what I changed in the last year or so ;)
1.06 Released 2008-10-08 by thetoof
- Fixed bug when using mode=6 with the checks
- Faster aa=4 when settings=0
- Fixed mt=false issues
- Fixed 1/2-pel registration error between the original and antialiased clip, due to EEDI2 for aa=1
- Fixed bug where edge masking was disabled with mc=false
- Added aatype argument to aa=4 (use sangnom or eedi2 for anti-aliasing)
- aapel's default is now 1 (faster)
- re-added idx for aa=4 (faster)
- Removed useless messages in the checks
- Changed AssumeFPS with ChangeFPS for region conversions
- Added RequestLinear call after cdeblend to prevent false "hey, it's not deblending well" assumptions when seeking
- Added AvsRecursion & aWarpsharp to the requirements archive
- Added corrected TempGaussMC_beta1mod
- Updated the docs to include the info on how to combine the lossless rendering pass and the analysis pass with vfr decimation
1.05 Released 2008-09-18 by thetoof
- Added string "edimode"
- Added int "degrain"
- Fixed typos in the docs
- Removed ineffective error message about the external audio file
- Added the plugins needed for aa=4 bob/precision=3 in the "requirements" archive & list
1.04 Released 2008-09-17 by thetoof
- Fixed check=3 and check=10 to be compatible with the new add-ons
- Corrected typo in the error message asking to specify the omode
- Disabled aa comparison when using one of the check=x
- nnedipel's default is now false
- Changed the order of the filters so that all the stream (not only the ivtced sections) can be processed with killcomb and aa
- Fixed syntax errors with mode=7
1.03 Released 2008-09-16 by thetoof
- Fixed bug when splicing clips at different framerates
- Fixed bug where frames were lost to decimation in mode=6
- Fixed bug causing the "tfm.txt" file to be overwritten every time the script was loaded
- Fixed idx values in the MVAnalyse and MVFlowFPS calls
- Use of 2 different pelclips if prefiltered clip is used before motion vectors calculation to prevent b0rked output
- Removed omode=3 for optimal vfr decimation
- Less memory usage by using a named clip for all the blankclips
- Changed syntax to be compatible with the newest version of mrestore
- Faster blends and duplicates detection for decimate=5 by using dclip=i.bob().reduceflicker(strength=1) in mrestore
- Replaced nnediaa with ediaa for better aliasing removal (aa=1)
- Added functions in the script to fix "There is no function named iseven/isodd" bug
- Added "MT" parameter to use with the multithreaded version of MVTools
- Added support for fieldblended PAL & norm-conversion restoration
- Added support for 30p credits on top of telecined background
- New check function to get the frame numbers of the 30p sections (check=0)
- New check function to see the prefiltered clip of the 30p sections (check=9)
- Argument "pureint" changed to "mix"
- 15 new "mix" modes for all the possibilities for 30p and 30i credits
- Replaced decimate=0 with pass=0
- New AA function by Mystery Keeper (aa=4)
- Re-added the possibility to use killcomb=0, but default remains 1
- Changed "precision"'s default to 3 for all modes
- Cosmetic changes
- Included TempGaussMC_beta1mod in the requirements package to make bob=3 work with the new "MT" parameter
- Docs update formatting improvement, reformulation here and there...
1.02 Released 2008-06-19 by thetoof
- No more "HD" setting (done automatically)
- Vinverse can't be removed from the filter chain, resulting in a speed improvement (killcomb=0 doesn't exist anymore)
- Decimate=0 can be used with any mode as a preparation to mode=7 (run a lossless rendering pass of decimate=0 and then load the resulting file with mode=7) for compressibility improvement through VFR
1.01 Released 2008-06-12 by thetoof
- Correction of syntax errors for mode=7
1.00 Released 2008-06-01 by thetoof
- Initial release of the function.