Jump to content
  • Sign Up
misseps

Avisynth: Blending aliasing fields after deinterlacing

Recommended Posts

misseps

I was wondering if what works in my avisynth script now can be (partially) automated or replaced by another function.

 

The DVD is PAL animation, that has between 25 and 50 unique images per second. I have to use extremely sensitive TDeint settings to avoid ghosting, any other deinterlacer causes ghosting (QTGMC) or more damage. A few field couples have aliasing (bobbing up and down), but they look clean after they are blended/merged together. The aliasing ones are always two (or three) frames that repeat each other.

 

It's not too bad for a few hunderd fields, but the entire video has over 60000 fields. Does anyone have any hints to clean up my code or knows a function that automatically blends the aliasing fields? I'll try to upload a sample later.

 

The part below is for the first 50:

 
f1=Trim(1, 1)

f2=Trim(2, 2)

f3=Trim(3, 3)

f4=Trim(4, 4)

f5=Trim(5, 5)

f6=Trim(6, 6)

f7=Trim(7, 7)

f8=Trim(8, 8)

f9=Trim(9, 9)
f10=Trim(10, 10)
fm9=Merge(f9,f10)

f11=Trim(11, 11)

f12=Trim(12, 12)

f13=Trim(13, 13)
f14=Trim(14, 14)
fm13=Merge(f13,f14)

f15=Trim(15, 15)

f16=Trim(16, 16)

f17=Trim(17, 17)
f18=Trim(18, 18)
fm17=Merge(f17,f18)

f19=Trim(19, 19)

f20=Trim(20, 20)
f21=Trim(21, 21)
fm20=Merge(f20,f21)

f23=Trim(23, 23)

f24=Trim(24, 24)

f25=Trim(25, 25)

f26=Trim(26, 26)
f27=Trim(27, 27)
fm26=Merge(f26,f27)

f28=Trim(28, 28)

f29=Trim(29, 29)

f30=Trim(30, 30)
f31=Trim(31, 31)
fm30=Merge(f30,f31)

f32=Trim(32, 32)

f33=Trim(33, 33)

f34=Trim(34, 34)
f35=Trim(35, 35)
fm34=Merge(f34,f35)

f36=Trim(36, 36)
f37=Trim(37, 37)
fm36=Merge(f36,f37)

f38=Trim(38, 38)
f39=Trim(39, 39)
fm38=Merge(f38,f39)

f40=Trim(40, 40)

f41=Trim(41, 41)

f42=Trim(42, 42)

f43=Trim(43, 43)
f44=Trim(44, 44)
fm43=Merge(f43,f44)

f45=Trim(45, 45)

f46=Trim(46, 46)

f47=Trim(47, 47)
f48=Trim(48, 48)
fm47=Merge(f47,f48)

f49=Trim(49, 49)

source = f1+f1+f2+f3+f4+f5+f6+f7+f8+fm9+fm9+f11+f12+fm13+fm13+f15+f16+fm17+fm17+f19+fm20+fm20+fm20+f23+f24+f25+fm26+fm26+f28+f29+fm30+fm30+f32+f33+fm34+fm34+fm36+fm36+fm38+fm38+f40+f41+f42+fm43+fm43+f45+f46+fm47+fm47+f49

 

Every field that's not part of a merge is unique or black. Every field that is merged looks aliased without blending. Merged frames are doubled to keep the output at 50fps. f22 is missing, since it is an aliasing field and the same as f20. Therefore fm20 is repeated once more.

 

Link to the sample: https://files.catbox.moe/8wrq2y.mpg

Edited by misseps

Share this post


Link to post
Share on other sites
Kuronoe

DVDPAL are terrible, especially the old or anime R18. Constantly I have problems with them, trimax is master in making this stupid conversion (not to mention the exaggerated crop), so sorry for the outburst.
 

If you have a 2 min cut from one of these scenes, it would help to think of a solution. Usually you can map as you are doing, but use an insert / replace frame, using a frame before or after (if it is the same and better). Another filter that often helps is "srestore.avsi". QTGMC alone does not usually work well, you need to tweak a few things, for example:

qtgmc (preset = "medium", fpsdivisor = 2 (keep fps), edimode = "eedi3 + nnedi3", sharpness = 0.10 ~ 0.20)

Maintaining 50fps won't help you at all, just increasing the amount of frames to watch or generate flickering frames.
Shapen only use up to 0.20 or it will warp your img, or not use it, preferably.

 

MAA2 () is a good filter for AA, but beware of the parameters aa and aac, they can make a curve turn a straight line. I recommend aa=20 and aac= 12. The aac is always -8 from aa.


Anyway, I don't know if it will help you. It's hard to say without a picture or even a cut of the video.

Share this post


Link to post
Share on other sites
Dani

It really depends on what your source is, although the course of action I would take doesn't vary much. If the source is progressive, either because it's sped-up 24fps animation (film-originating North American cartoons* or anime) or 25fps European cartoons, you don't really need to do anything, but it sounds like this isn't the case. (In case of a sped-up source, you might consider slowing it back down to the original speed.) If there's just a little bit of combing here and there from editing such a telecine on an old video editor, just about any deinterlacer will do, though you'll probably want to damage the animation as little as possible doing so. I find yadif works best for this.

 

On the other hand, you'll frequently find shows 4-field converted from NTSC video, in which case there will be combing EVERYWHERE and even worse, all the frames will have severe blending... unfortunately, it doesn't matter what you do with a source like this, because there's no good way to reverse this garbage, other than finding a source that doesn't have this problem**. (Meaning, try to find an NTSC source in this case.) Once again, I find yadif to have the best handling for this situation.

 

*there are of course exceptions where the originating video standard does not match the country of origin. I've found way too many Canadian cartoons that were mastered in PAL for some reason.

 

**I know of at least one case where this is impossible, because the idiots*** who made it threw out the original non-converted master.

 

***I'm sure no one will be surprised to learn that Toei are said idiots.

 

Edit: Ok, I saw you added a sample. And hey, what the crap? Totally Spies was 4-field converted when it aired on Canadian (NTSC) TV, so what the hell did they do with the PAL version?

 

Edit 2: Ok, I examined the video closely. To my immense relief, this appears to be 25fps animation that was simply sped up with an old video editor. Unfortunately there's no way to truly recreate this effect progressively, short of getting the original footage and literally re-editing it all progressively. (This is why most cartoons from the early 2000s and late 90s will never be remastered in HD. They were ALL edited this way and redoing all the edits in progressive HD would cost almost as much as completely remaking the show from scratch. Assuming the animation elements still exist, which they frequently don't.)

 

You can use field-doubling to try and replicate the way it'd look on a CRT, like you appear to have been trying, but imo it's not worth it, a normal 25fps deinterlace will suffice.

 

(This method of editing is also WHY 4-field conversion tended to be used in these cases. It was the only way available with the primitive technology of the time... the 2000s.)

 

You have no idea (or I guess, some idea, if you read this far) how fortunate it is that virtually all TV production, and as far as I'm aware, ALL animation is edited progressively these days.

Edited by dangerousvhs

Share this post


Link to post
Share on other sites
misseps

Thanks for the replies! I forgot to add a sample, that is added now.

3 hours ago, Kuronoe said:

Maintaining 50fps won't help you at all, just increasing the amount of frames to watch or generate flickering frames.

The main reason I want to maintain 50fps is that VFR does not really work on my equipment properly and I'd rather not remove unique 'images'. When removed, it looks less smooth.

17 minutes ago, dangerousvhs said:

It really depends on what your source is, although the course of action I would take doesn't vary much. If the source is progressive, either because it's sped-up 24fps animation (film-originating North American cartoons* or anime) or 25fps European cartoons, you don't really need to do anything, but it sounds like this isn't the case. (In case of a sped-up source, you might consider slowing it back down to the original speed.) If there's just a little bit of combing here and there from editing such a telecine on an old video editor, just about any deinterlacer will do, though you'll probably want to damage the animation as little as possible doing so. I find yadif works best for this.

 

*there are of course exceptions where the originating video standard does not match the country of origin. I've found way too many Canadian cartoons that were mastered in PAL for some reason.

It's should be PAL natively (produced in France).

Where those Canadian cartoons also done in Korea or by Marathon? That might explain the PAL masters.

Edited by misseps

Share this post


Link to post
Share on other sites
Dani
3 minutes ago, misseps said:

Thanks for the replies! I forgot to add a sample, that is added now.

The main reason I want to maintain 50fps is that VFR does not really work on my equipment properly and I'd rather not remove unique 'images'.

It's should be PAL natively (produced in France).

Where those Canadian cartoons also done in Korea or by Marathon? That might explain the PAL masters.

You're right, it is native PAL. I've already updated my post with my analysis of the sample you posted. (And thank you, I rarely get to have such a look at both sides of the pond!)

The most notable example of a Canadian cartoon mastered in PAL, and the one I currently have the most evidence for, is Reboot. Animated in VANCOUVER by Mainframe, so figure that out.

Edited by dangerousvhs

Share this post


Link to post
Share on other sites
Kuronoe

well, qtgmc worked very well for me.
Notice below.

My test.

 

Your src is not as bad as most things I usually work on, just study the use of the filter. Qtgmc has many parameters, but it is far superior to yadiff, it is very obsolete these days and leaves many artifacts in the video. Qtgmc has the defect of slightly blurring the lines, but in DVDPAL this already happens by mistake in conversions, so the minimal sharpen helps to clean around the lines without distorting the video.

cya.

Share this post


Link to post
Share on other sites
Dani
1 hour ago, Kuronoe said:

well, qtgmc worked very well for me.
Notice below.

My test.

 

Your src is not as bad as most things I usually work on, just study the use of the filter. Qtgmc has many parameters, but it is far superior to yadiff, it is very obsolete these days and leaves many artifacts in the video. Qtgmc has the defect of slightly blurring the lines, but in DVDPAL this already happens by mistake in conversions, so the minimal sharpen helps to clean around the lines without distorting the video.

cya.

Personally, I use yadif specifically because it doesn't blur the image. Note that this DVD has not been converted from NTSC, 576i is its native resolution.

Share this post


Link to post
Share on other sites
misseps
14 hours ago, Kuronoe said:

well, qtgmc worked very well for me.
Notice below.

My test.

 

Your src is not as bad as most things I usually work on, just study the use of the filter. Qtgmc has many parameters, but it is far superior to yadiff, it is very obsolete these days and leaves many artifacts in the video. Qtgmc has the defect of slightly blurring the lines, but in DVDPAL this already happens by mistake in conversions, so the minimal sharpen helps to clean around the lines without distorting the video.

cya.

Problem I had with QTGMC is that at some points it will cause ghosting (mostly at 50fps, for example this sample, it is most noticable in the blonde hair during movement: https://files.catbox.moe/hslub8.mpg) . Right now the only deinterlacing I found that avoids ghosting is

TDeint(mode=1, type=3, slow=2, full=false, MI=16, edeint=nnedi3(field=-2, nns=4, pscrn=4, qual=2), emask=TMM(mode=1, order=1, mtype=2))

.

Here's an example of the output of the entire file with all those seperate trim/merge segments: https://files.catbox.moe/wyqssb.mkv

Share this post


Link to post
Share on other sites
Dani

Just as I said, the reason I go with yadif is because I found it to add the fewest problems to the video. I've previously experimented with a bunch of different filters, (including QTGMC I think) I even used to use one that I thought created fewer artifacts but it turned out to be at the very significant cost of frequently leaving in combing. And if you think I'm wrong... that's fine. In my opinion it's mostly subjective, and most people (even me...) won't notice the difference unless whatever filter you used causes very significant problems. Also that it's impossible to have a 100% accurate representation of how interlaced video is supposed to look without watching it on an actual interlaced display. (CRT only.) Not only is it already rather unreasonable to ask someone to watch old shows exclusively on an old CRT TV, but one day there likely won't be any working CRTs at all anymore, so I'd rather something that looks mostly acceptable. (And also, most modern video formats don't support interlacing, I think H264 is the newest format that does, and its support doesn't seem to be particularly good either.)

 

(And here's something for the paranoid... if you look at the individual fields before deinterlacing, I think you'll find that there's already artifacting in the video created by the cheap methods video editing software from that time used. So you can never win there.)

Share this post


Link to post
Share on other sites
mcmxcixmm

@misseps

Your sample is telecined, NOT interlaced! You need to use the TFM filter from the TIVTC package, possibly along with TDecimate.

If you use a deinterlacing filter, not only will it have a harder time getting the job done but you also unnecessarily lose information!

 

@Kuronoe

@dangerousvhs

Never, ever use yadif or QTGMC for animated content. This is something I've learned the hard way.

Both leave artifacts that can be extremely difficult to spot just scanning a few frames here and there, but when you actually watch the entire output... oh dear.

 

If it can't simply be detelecined with TIVTC, try daa3 (for very sensitive, mostly-progressive content where ghosting isn't an issue) or nnedi3 (if ghosting appears with daa3) - but be aware that nnedi3 will destroy any actually progressive frames, so if the source has a mix it should be done manually, frame-by-frame.

Share this post


Link to post
Share on other sites
misseps
45 minutes ago, mcmxcixmm said:

@misseps

Your sample is telecined, NOT interlaced! You need to use the TFM filter from the TIVTC package, possibly along with TDecimate.

If you use a deinterlacing filter, not only will it have a harder time getting the job done but you also unnecessarily lose information!

Problem is that in some parts I will lose information because there are 50 unique fields (and it will look jerky). Here's the entire outro encoded (check for example around 16/21 seconds, during the panning shots): https://files.catbox.moe/wyqssb.mkv

Share this post


Link to post
Share on other sites
mcmxcixmm
3 hours ago, misseps said:

Problem is that in some parts I will lose information because there are 50 unique fields (and it will look jerky). Here's the entire outro encoded (check for example around 16/21 seconds, during the panning shots): https://files.catbox.moe/wyqssb.mkv

No, TFM is specifically designed for these types of cases. It knows that some of the alternating fields are unique, and some aren't. That's the nature of telecining.

Deinterlacing filters have no way of knowing this, so they do lose a lot of information from the original video stream.

 

That sample looks basically perfect to me, except for the text shimmering on the left.

I even slowed down the panning shots in that interval, and still couldn't see any issues with them.

 

I would recommend trying out TDecimate afterwards though. That filter works to drop duplicate frames left behind by TFM. Personally I'm not too fond of it because I prefer to keep the original framerate whenever possible, but if you still think it looks jerky...

Share this post


Link to post
Share on other sites
Spoony

Haven't read all the posts, but have you tried nnedi3? I've had some really good results in the past deinterlacing with it.

Share this post


Link to post
Share on other sites
mcmxcixmm
2 hours ago, SpoonyBard said:

Haven't read all the posts, but have you tried nnedi3? I've had some really good results in the past deinterlacing with it.

As I wrote in one of said posts, nnedi3 is very problematic for mixed content (like the sample clip here) because it destroys progressive frames.

It's great for purely interlaced content, but if you have a mix you have to specify which frames to deinterlace manually, or you lose an enormous amount of quality.

 

daa3 is fundamentally based on nnedi3, but it leaves progressive content virtually untouched. The downside is that if there's motion in the scene (not just combing), it causes ghosting.

Share this post


Link to post
Share on other sites
misseps
11 hours ago, mcmxcixmm said:

No, TFM is specifically designed for these types of cases. It knows that some of the alternating fields are unique, and some aren't. That's the nature of telecining.

Deinterlacing filters have no way of knowing this, so they do lose a lot of information from the original video stream.

 

That sample looks basically perfect to me, except for the text shimmering on the left.

I even slowed down the panning shots in that interval, and still couldn't see any issues with them.

 

I would recommend trying out TDecimate afterwards though. That filter works to drop duplicate frames left behind by TFM. Personally I'm not too fond of it because I prefer to keep the original framerate whenever possible, but if you still think it looks jerky...

That sample I uploaded was encoded at 50fps with:

TDeint(mode=1, type=3, slow=2, full=false, MI=16, edeint=nnedi3(field=-2, nns=4, pscrn=4, qual=2), emask=TMM(mode=1, order=1, mtype=2))

and manually checking if anything should've been merged when aliasing:

f20=Trim(20, 20) f21=Trim(21, 21) fm20=Merge(f20,f21)

 This doesn't look jerky and is how it looks displayed on a CRT.

TFM encoded sample (so at 25fps) https://files.catbox.moe/e41myt.mkv. Especially when compared it looks jerky.

Another example of mixed footage (unencoded): https://files.catbox.moe/yyieud.mpg. The slidings doors seem to be at 50 uniques per second while the people storming through are at I guess mostly 25 uniques per second. Seems like they either sped up the tapes or this was edited in video software from around 2000 (which has its limitations).

Edited by misseps

Share this post


Link to post
Share on other sites
mcmxcixmm

@misseps You seem to think the show couldn't have been originally animated at different "unique" frame rates. This is completely false - animation is generally done "on twos", but shifts to "on ones" when quality is deemed more important than cost savings. In other words, the "different" frame rates may very well have been intentional, not artifacts introduced later!

Furthermore, I still do not see any jerkiness whatsoever, so I cannot understand why you think there's something wrong with the detelecined footage.

 

Also I'm really confused about your samples - I thought the original one was actual raw footage, but now you're saying it was "encoded" at 50 fps?

Then you say the second-last sample is done with TFM, yet it shows horrible deinterlacing artifacts (exactly what I was warning about with nnedi3)?

Are you sure your samples aren't mixed up?

Edited by mcmxcixmm

Share this post


Link to post
Share on other sites
misseps
25 minutes ago, mcmxcixmm said:

@misseps You seem to think the show couldn't have been originally animated at different "unique" frame rates. This is completely false - animation is generally done "on twos", but shifts to "on ones" when quality is deemed more important than cost savings. In other words, the "different" frame rates may very well have been intentional, not artifacts introduced later!

Furthermore, I still do not see any jerkiness whatsoever, so I cannot understand why you think there's something wrong with the detelecined footage.

 

Also I'm really confused about your samples - I thought the original one was actual raw footage, but now you're saying it was "encoded" at 50 fps?

Then you say the second-last sample is done with TFM, yet it shows horrible deinterlacing artifacts (exactly what I was warning about with nnedi3)?

Are you sure your samples aren't mixed up?

Sorry I'm a bit confusing, English is not my first nor second language. All the .mkv files are encoded, all the .mpg files are unencoded samples.

 

Some clips from an episode in the outro are sped up to some degree. I know this because the clips used in the outro are played faster compared to the scenes in the actual episodes.

In the actual episodes it is like you said: animated at different frame rates (like in this clip: https://files.catbox.moe/yyieud.mpg).

 

This is what happens if I use TFM only: https://files.catbox.moe/e41myt.mkv

This is what happens when I use what I am describing in my first post (TDeint + manual merge): https://files.catbox.moe/wyqssb.mkv

 

I hope it's clearer now.

Edited by misseps

Share this post


Link to post
Share on other sites
Dani
17 hours ago, mcmxcixmm said:

Never, ever use yadif or QTGMC for animated content

Well I got bad news for you.

Spoiler

Half a decade of TV rips. Almost all deinterlaced with yadif.

 

Share this post


Link to post
Share on other sites
mcmxcixmm

@misseps

So TFM leaves behind awful deinterlacing artifacts, but an actual deinterlacer doesn't? Can't say I've seen that before...

Did you try setting TFM's parameters, particularly those for PAL vs. NTSC field patterns?

 

Once again though, I'm still not seeing any jerkiness anywhere - just deinterlacing artifacts (jagged lines).

 

3 hours ago, dangerousvhs said:

Well I got bad news for you.

  Reveal hidden contents

 

Yes, I know - that's partly why I wrote that. 😛 You also still use AVIs and H.263, long after both have been made virtually obsolete.

It seems to be a thing with the few Canadian encoders I know actually. OTOH Canadian media is treated so poorly that you guys often don't have high-quality sources to work with anyway.

Share this post


Link to post
Share on other sites
Dani
2 hours ago, mcmxcixmm said:

Yes, I know - that's partly why I wrote that. 😛 You also still use AVIs and H.263, long after both have been made virtually obsolete.

It seems to be a thing with the few Canadian encoders I know actually. OTOH Canadian media is treated so poorly that you guys often don't have high-quality sources to work with anyway

I stopped using AVI* and H.263 (specifically Xvid) earlier this year last year. Yeah, took me long enough. Anything you see me still releasing like that was encoded that long ago.

*AVI is still used for lossless inbetweens, but those aren't uploaded for obvious reasons (asking you to download 100GB episodes would be slightly unreasonable)

 

And yeah, you're right the sources are crap. For me HDTV means MPEG-2, usually under 7mbps (estimated).

Edited by dangerousvhs

Share this post


Link to post
Share on other sites
badguys
On 11/23/2019 at 1:23 PM, mcmxcixmm said:

@misseps

Your sample is telecined, NOT interlaced! You need to use the TFM filter from the TIVTC package, possibly along with TDecimate.

If you use a deinterlacing filter, not only will it have a harder time getting the job done but you also unnecessarily lose information!

 

@Kuronoe

@dangerousvhs

Never, ever use yadif or QTGMC for animated content. This is something I've learned the hard way.

Both leave artifacts that can be extremely difficult to spot just scanning a few frames here and there, but when you actually watch the entire output... oh dear.

 

If it can't simply be detelecined with TIVTC, try daa3 (for very sensitive, mostly-progressive content where ghosting isn't an issue) or nnedi3 (if ghosting appears with daa3) - but be aware that nnedi3 will destroy any actually progressive frames, so if the source has a mix it should be done manually, frame-by-frame.

I use EEDI2 Bob on purely interlaced content in Handbrake (I use Vidcoder) with the interlace detection set to "fast", and it put out a suitable output for me.  I don't upload on here since my encodes are usually minis that I make for myself.

 

On 11/24/2019 at 11:14 AM, dangerousvhs said:

I stopped using AVI* and H.263 (specifically Xvid) earlier this year last year. Yeah, took me long enough. Anything you see me still releasing like that was encoded that long ago.

*AVI is still used for lossless inbetweens, but those aren't uploaded for obvious reasons (asking you to download 100GB episodes would be slightly unreasonable)

 

And yeah, you're right the sources are crap. For me HDTV means MPEG-2, usually under 7mbps (estimated).

HDTV in the air over here goes as high as 15mb/second (ATSC supports up to 19.39mb/second, but the video and audio can only take 18.3mb/second due to adding other data) for one video stream on a broadcast channel.  However, I don't have the utilities to capture from the air.

Share this post


Link to post
Share on other sites
Dani

Yeah, I'd very much like to be able to cap OTA, but for now I'm working with what I've got. As far as what's on Canadian OTA stations goes, CBC, Radio-Canada and TVO would be the only ones relevant here anyway.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...