View Full Version : 3:2 video pulldown, avisynth and TMPGENC.. somebody explain it to me.
Rain_1
27th December 2005, 05:30
Ok.. so i'm back with the very same problem that has haunted me since i started encoding video - Deinterlacing...
Actually, i only have a problem encoding cartoons. On live action stuff, tomsmocomb does a perfect job - but when it comes to animation overall, i just can't understand it.
ok.. so, luckily, every single cartoon/anime i always captured from my tv has been in a 3:2 format... and by that, i mean that there's 2 bad (combed, interlaced, whatever you call it) frames, and 3 good ones.
Now, as i learned on TMPGENC, that's an easy thing to fix. Just get those 2 frames, split their frames and reconstruct the missing frame using field A of one frame and field B of the other frame (and if i'm wrong, please, somebody correct me now).
Why i just can't find a filter that does exactely that for avisynth? I tried TIVTC, TDeint and a number of different filters, and i never managed to get it to work properly.
One filter comes up to mind (i don't really remember which), but i had to set thresholds and whatnot for it to detect the combed frames and then try to work them up - i couldn't just tell it to follow a 2bad3good pattern - which i can easily on tmpgenc.
So yeah... what am i doing wrong here? TMPGENC never had a problem inverse telecining animation for me (but then again, TMPGENC kinda sux for what i want.. i can't pre-proccess the video, it's IVTC is kinda slow and i'd have to frameserve it somewhere else - too much hassle).. if there was a filter for avisynth that did exactely that (and didn't try to LOCATE the bad frames - it just can't locate the mouthcombs without detecting everything else as a combed frame aswell) twice slower than TMPGENC, i'd be one happy encoder...
So, please, again, i know this is getting annoying, but could anybody shed some light on this subject? i've been using this .AVS script and i've been getting the linked images as result (not good enough.. notice the horrible mouthcombs and bad processing)
LoadPlugin("c:\avs\TIVTC.dll")
LoadPlugin("c:\avs\Bifrost.dll")
LoadPlugin("c:\avs\fft3dfilter.dll")
loadplugin("c:\avs\awarpsharp.dll")
LoadPlugin("c:\avs\guavacomb.dll")
LoadPlugin("c:\avs\MaskTools.dll")
Import("d:\LimitedSharpen.avs")
AviSource("d:\harvey cortado.avi")
GuavaComb(Mode = "PAL", Recall = 75, MaxVariation = 25, Activation = 40)
TFM(mode=6,PP=7,slow=2,mChroma=false)
TDecimate(mode=1)
ConvertToYV12
BiFrost(interlaced=false)
FFT3DFilter(sigma=1,bt=3,bw=32,bh=32,ow=16,oh=16)
Crop(32,2,-18,-4)
aWarpSharp(depth=16,cm=1)
Lanczos4Resize(640,480)
LimitedSharpen()
I can't use the mChroma in TFM because of heavy rainbowning..
Images:
http://rain01.free.fr/cap/snapshot20051227020536.jpg
http://rain01.free.fr/cap/snapshot20051227020541.jpg
I did everything i could find out about deinterlacing - short of manually override the combed frames (which i can't believe is the only way out. TMPGenc does it without any manual overriding, there must be a way to do it here aswell)
I don't even want a right answer that will make everything work correctly (if you have one, i will appreciate it tho.. :D), i just want some explanation if i got anything wrong on my way of thinking... because i seriously can't think of anything else, and that would lead me to believe that tmpgenc manages to use sorcery to IVTD videos.
anything (and i mean anything) is appreciated... thank you for even bothering to read this...
Chainmax
27th December 2005, 13:53
Didn't I recommend you to read all of Decomb's documents and the IVTC tutorial a while back? If so, have you read them? Read them again, and in the meantime post a sample vob (or an avi chunk if it's a capture) so that we can examine. After you read the stuff I mentioned, I'll give you an explanation to the best of my limited knowledge regarding interlacing, telecine, and how to get rid of them.
foxyshadis
27th December 2005, 16:09
You might just have a really bad capture, that requires more preprocessing than just guavacomb, because those mouths aren't just combed, they're trashed. In particular, NTSC tends to have a lot of temporal ghosting. If TFM gets garbage in, it gives garbage out.
I second the notion of an unprocessed sample.
Rain_1
27th December 2005, 17:01
I've read the guides about a million times already... i just can't figure out what's wrong....
Here are the samples - mind you, they're a little big because they're raw 720x480 mjpeg encodes. The raw one is 60 megs (i could've made it 20, but i wanted to show you 4 different examples of what's going on)..
http://shiznitz.free.fr/sealab_raw.avi
http://shiznitz.free.fr/sealab_encoded.avi
On the videos there's 4 scenes. First, the captain is talking, alone on the screen. on the processed video, his mouth gets funny shadows (when he looks up) that are not supposed to be there - even tho none of that sequence is apparently interlaced..
Then it's a wide shot of all three.. the captain's mouth still has problems, even tho there's again, no apparent interlacing there...
Then it's some dude's scene... again, mouth problems everywhere and again, no interlacing apparent on the raw video..
Then it's a wide shot again, with all 3... now on that shot there's interlacing on the captains mouth before the puts his shoulders up - and that get's treated well...
But, on the other encode i posted pictures of (which raw i don't have anymore), there were interlacing on shake's mouth on those particular scenes, and that was the end result of it.
So, apparently, it's detecting interlaced frames on frames that aren't really interlaced - which yes, is prolly mostly because of my noise source (analogue cable tv) - which then again brings me back to my first question - why there isn't an avisynth script/plugin that will just follow a pattern i give to it (2 frames bad, 3 good, for instance), just like tmpgenc's IVTC, instead of trying to detect interlaced frames?
Chainmax
27th December 2005, 20:03
I agree with foxyshadis that there must be something wrong with the source, and from the screenshots (haven't downloaded the sample yet), it seems like some kind of ghosting/blending, which seems logical since as per you script I see that your source is PAL. The TFM/TDecimate lines you used give you a 23.976fps output from an NTSC (29.97fps) source. Maybe CDeBlend could be a better choice, you'll have to ask the experts (Didée, MOmonster, foxyshadis, etc) on this one.
By the way, you should read Bifrost's readme: if the rainbows follow a certain pattern (described in the readme), you have to use it before IVTCing using Bifrost() and that might be all you need for rainbow removal. Using Bifrost at a wrong place in your script renders it useless. If you're using GuavaComb for dotcrawl removal, I advice you to use DeDot() (http://nullinfo.s21.xrea.com/#DeDot_YV12) instead. Your script would start like this:
BiFrost() <-- if rainbows are Type 1
ConvertToYV12(interlaced=true)
DeDot()
Bifrost(interlaced=false) <-- if rainbows are Type 2
rest_of_the_filters
Rain_1
27th December 2005, 20:22
The TFM/TDecimate lines you used give you a 23.976fps output from an NTSC (29.97fps) source.
Except i have PAL-M, meaning 29,97 fps and 60hz, but with PAL color "mode"... Applying NTSC filters to it meant nothing - PAL filters on the other hand, have been working nicely.
By the way, you should read Bifrost's readme: if the rainbows follow a certain pattern (described in the readme), you have to use it before IVTCing using Bifrost() and that might be all you need for rainbow removal. Using Bifrost at a wrong place in your script renders it useless. If you're using GuavaComb for dotcrawl removal, I advice you to use DeDot() (http://nullinfo.s21.xrea.com/#DeDot_YV12) instead. Your script would start like this:
I'm pretty happy with the rainbow removal from my script - it just doesn't work on moving scenes, but that's how it's supposed to work.
Also, i do have copies of the rainbowining effect every 5 frames.. Well, more like 4.. frames 1 2 3 4 are totally different amongst themselves, but frames 5 6 7 8 are exactely the same as frames 1 2 3 4 (when it comes for rainbows.. i can tell because it's the frozen logo of sealab2021 at the end of the episodes).. thus, i do have to deinterlace it first...
DeDot is even quoted on my script, because i was using it before, but it never provided me with good enough results - i'm guessing it's because i have PAL-M instead of NTSC..
foxyshadis
27th December 2005, 22:22
Checking out your clip, the moire is horrific. :o You have serious interference on whatever line you're capturing on, and that needs to be taken care of before any deinterlacing. If it's cable or antenna and the problem isn't anything you can fix, try DeFreq (http://www.avisynth.org/fizick/defreq/defreq.html). That should take care of much of the problem, along with dotcrawl removal.
The final mouth-comb looks like a field-order problem. Something got swapped in capture. The rest of the video looks fine from an interlacing standpoint, you don't need IVTC/deinterlacing at all. (Unless it has a mode to correct field mismatches like frames 501/503.)
I've never captured video myself, this should probably be moved to capture forum where you might be able to get better responses.
If anyone wants to see it without spending an hour downloading, I uploaded an interesting segment to my site (http://foxyshadis.slightlydark.com/random/sealab_raw1.avi).
tritical
27th December 2005, 22:36
I can almost guarentee the artifacts in the pics in your first post are from the guavacomb line. If you take out it are they still there?
why there isn't an avisynth script/plugin that will just follow a pattern i give to it (2 frames bad, 3 good, for instance), just like tmpgenc's IVTC, instead of trying to detect interlaced frames? tfm's overrides allow you to specify a matching pattern or combed/not combed pattern over a range of frames, for example:
70,100 ++---
would deinterlace frames 70,71 and keep 72,73,74 untouched, and then repeat that pattern every 5 frames up to frame 100. You can do the same thing with a matching pattern, for example:
70,100 ppccc
will repeat the ppccc pattern every 5 frames from frame 70 to frame 100. So if you simply wanted to have everything match 'c' and deinterlace only a few specific frames (say 50 and 57) you could have the following overrides file:
0,0 c
50 +
57 +
and then add "ovrdefault=1" and "ovr="override_file.txt" into your tfm() line. ovrDefault=1 makes it so that any frames not explicitly marked as combed '+' in the ovr file are treated as being marked not combed '-'. That said, using the following seems to work fine and corrects the mismatches on frames 501/503 in the sample you posted:
avisource("C:\sealab_raw.avi")
crop(32,4,-16,-4)
tfm(mode=4,mchroma=false)
Rain_1
27th December 2005, 23:27
Checking out your clip, the moire is horrific. :o You have serious interference on whatever line you're capturing on, and that needs to be taken care of before any deinterlacing. If it's cable or antenna and the problem isn't anything you can fix, try DeFreq (http://www.avisynth.org/fizick/defreq/defreq.html). That should take care of much of the problem, along with dotcrawl removal.
Yeah, i'm aware of the interference - thus, why it's so heavy filtered... but, considering the speed-wise of the encode (6 hours for 2pass xvid of 15 minutes episode), the result is pretty good (except for the mouth problems addressed on this topic). Also, there's nothing i can do about it (tried to fix it countless times.. it goes on and off - apparently, it's something not even on my cabling).
The final mouth-comb looks like a field-order problem. Something got swapped in capture. The rest of the video looks fine from an interlacing standpoint, you don't need IVTC/deinterlacing at all. (Unless it has a mode to correct field mismatches like frames 501/503.)
While the piece of video i gave does suggest that there's almost no interlacing, that is misleading. There's much more interlacing than that - it's just that Sealab 2021 is such a non-movement cartoon that most of the interlacing doesn't show up - but it's there.
If anyone wants to see it without spending an hour downloading,
It really took you one hour? free.fr is usually fast for me...
I can almost guarentee the artifacts in the pics in your first post are from the guavacomb line. If you take out it are they still there?
I'll be damned... removing guavacomb did remove the mouth artifacts (let's call it that from now on). But, as a side effect, it didn't remove some problems of the video (like intereference) and i'm pretty sure it didn't remove rainbow effects either (no rainbow on that particular sequence of the cartoon). Also, it created a weird problem: it created mouthcombs on frame 144. ( http://rain001.free.fr/capture/combed.png ). That's weird, that frame is not combed on either the raw video or the previously encoded (with guavacomb) video...
tfm's overrides allow you to specify a matching pattern or combed/not combed pattern over a range of frames
I never figured out you could force a pattern through override. I though it was soleny for specifying whihc frames you wanted to force a deinterlace or not - not for applying patterns... interesting, i must test that...
MOmonster
27th December 2005, 23:52
@rain_1
I needed a half hour for it, but I couldn´t finish the download from foxyshadis :confused: .
Because the source is a typical 12fps anime and the croma artefacts are only for one framelength, this is not the big problem. You need just a function that use the next frame with the same content but without these artefacts instead.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.