Log in

View Full Version : Question about Deinterlacing


Blaze_Heatnix
28th December 2011, 00:11
I'll try to make this as simple and short as I can.

Basically, I am testing some things right now with a 30fps interlaced clip. What I want to do is to keep it at 30fps, not double to 60. So is there some sort of filter or anything that can achieve the same thing as:
assumeframebased()
separatefields()
lanczosresize(width,height)
changefps(30)

Doing it as flawlessly, yet without having to use a resize command.

nhope
28th December 2011, 02:22
None of the deinterlacing methods I know include resizing. Why don't you want to use a resize command?

You can use SelectEven() or SelectOdd() to get it back to 30fps after deinterlacing. If you use the state-of-the-art deinterlacer QTGMC (http://forum.doom9.org/showthread.php?t=156028) you can use the option FPSDivisor=2.

Also if you are downscaling you get a small speed advantage if you resize the width before the deinterlacing and the height afterwards.

So example code might look like this:

AssumeTFF
LanczosResize(1280,height)
QTGMC(FPSDivisor=2)
LanczosResize(width,720)

Blaze_Heatnix
28th December 2011, 03:02
Well, I'm working with a 720x480 video and I'm actually upscaling it to 1280x720. It's stupid, I know, but it's just a test video to be uploaded to Youtube once I get everything straightened out, and Youtube ruins quality like nothing else so people are pretty much inclined to upload at 720p to make it look at least look like decent 480p footage on that site.
I have tried QTGMC, but it's too slow for me. My PC isn't that good for many of the more powerful filters being used at once, and since I'm upscaling, I'm using Limitedsharpenfaster just to give it a bit more detail.
I've chosen Fielddeinterlace(dthreshold=8) in tests, but Blending Fields genarally doesn't look that great. I thought I'd ask here just incase I might be able to get something like assumetff().separatefields().lanczosresize(width,height).assumeframebased just without having to re-resize it so to speak.

Guest
28th December 2011, 03:34
Well, I'm working with a 720x480 video and I'm actually upscaling it to 1280x720.... I thought I'd ask here just incase I might be able to get something like assumetff().separatefields().lanczosresize(width,height).assumeframebased just without having to re-resize it so to speak. First you say you are upscaling and then you say you want to eliminate the resize. It makes no sense. If you post your entire script we have a chance of knowing what you mean by "re-resizing".

Anyway, doing what you are doing is bad because the separatefields() shifts the second field out of position.

Tell us what you actually have and what you want. Is your source 720x480 @ 60i (interlaced) and you want 1280x720 @ 30p (progressive)? If not, then please advise. And I'm wondering if you really have in fact 720x480 @ 59.94i, which will complicate the conversion to 1280x720 @ 30p.

If so, then one option is to just use a good single-rate deinterlacer, then upscale as needed. Or, use a good bobber, toss every other frame, and then upscale.

Finally, the aspect ratios of 720x480 and 1280x720 are different. You'll have to allow for that with black borders if you want to keep the original aspect ratio.

Regarding blending by FieldDeinterlace(), you can add the parameter blend=false to avoid blending. But there are better deinterlacers for pure interlaced content than FieldDeinterlace(), which is intended for post-processing of field matched frames as part of an IVTC operation.

Blaze_Heatnix
28th December 2011, 04:16
Oh boy, let me see here. Well, it's kind of complicated to me. You might have to see my source to understand what I'm trying to do. My source is actually footage from a PS3. PS3 footage is 16:9(?) and I'm recording from that at 720x480 because I only have an SD capture device. That isn't 16:9, so I'm upscaling it like that to get it back to 16:9. Also, my source ISN'T double NTSC, it's only 29.97fps.
I guess I'll post my test source for you guys to see. http://www.megaupload.com/?d=QDYU1ZTD
The script I have now is:
avisource("test.avi")
fielddeinterlace(dthreshold=8)
#assumetff().separatefields().lanczosresize(width,height).assumeframebased()
converttorgb32
crop(0,0,-2,-4)
#trim(97,97)
lanczosresize(1280,720)
ConvertToYV12()
import("C:\Program Files\AviSynth 2.5\plugins\LimitedSharpenFaster.avs")
LimitedSharpenFaster

I also know about Fielddeinterlace(blend=false), but It leaves jagged lines so I'm not sure. I'm really not good with deinterlacing so please go easy on me, heh.

Guest
28th December 2011, 04:38
What is your desired output frame rate?

Blaze_Heatnix
28th December 2011, 04:41
What is your desired output frame rate?

Simply to keep it as it is at 29.97.

nhope
28th December 2011, 05:44
Try this. Yadif is very fast but makes a pretty good job of deinterlacing. LSFmod is a bit faster than LimitedSharpenFaster.

YouTube will serve 984x720 as HD. No need to pillarbox it with black borders.

LoadCplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\yadif.dll")
AviSource("Blaze_Heatnix.avi")
ConvertToYV12(interlaced=true, matrix="PC.709")
AssumeBFF()
Crop(2,0,-2,-4)
yadif()
LanczosResize(984,720)
LSFmod(strength=300, edgemode=1)

Blaze_Heatnix
28th December 2011, 06:24
Try this. Yadif is very fast but makes a pretty good job of deinterlacing. LSFmod is a bit faster than LimitedSharpenFaster.

YouTube will serve 984x720 as HD. No need to pillarbox it with black borders.

LoadCplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\yadif.dll")
AviSource("Blaze_Heatnix.avi")
ConvertToYV12(interlaced=true, matrix="PC.709")
AssumeBFF()
Crop(2,0,-2,-4)
yadif()
LanczosResize(984,720)
LSFmod(strength=300, edgemode=1)

That works ok-ish, however there is alot of detail missing (like some of the stars in the background are missing). It looks a tad sharper and darker, but yadif leaves a bit of artifacts from the deinterlacing. Also, I learned that messing with Video Game footage in YV12 colorspace is generally a no-no. By the way, Youtube would actually Pillarbox 984x720, not 1280x720 (I'm pretty sure anyway, either way, 1280x720 isn't pillarboxed). LSFmod seems to be ever so slightly better than limitedsharpenfaster, so that's good.

The funny thing though, I could have sworn I did something like deinterlace a video similar to the one I'm using to test now, but getting the result I'm looking for (deinterlacing and converting to 30fps without the artifacts left from a filter). It's all so very confusing, heh :(

nhope
28th December 2011, 06:40
Yes, YouTube will add black bars to the sides in the player, but you'll have to do that yourself to render 1280x720, unless you are happy to stretch your video horizontally.

I would look at QTGMC again. Try to get it working in multi-threaded mode using SEt's latest build of AviSynth 2.6 and -Vit-'s modded plugins pack. It has some pretty fast modes. Try "super fast".

TheSkiller
28th December 2011, 11:24
YouTube will not add pillarboxes to the video, any pillarboxing one might see is generated during playback. Uploading in 984x720 to YouTube is perfectly fine, no need to pillarbox or stretch (yuck!) to 1280.

(...) and Youtube ruins quality like nothing else so people are pretty much inclined to upload at 720p to make it look at least look like decent 480p footage on that site.You're right, although I find it stupid I have stopped uploading in anything but 720p for that reason. Also, still to this day YouTube does deny the existence of PAL by not offering 576p. If one uploads a video of say 768x576 they just resize it down to 640x480 before they do their encode and present it in 480p! Another reason to upscale to 720p...

Blaze_Heatnix
29th December 2011, 01:33
Well you guys, remember, I'm not trying to acheive the aspect ratio of my recording. I want the aspect ratio of PS3 footage (with which I'm upscaling would be iirc somewhere between 1080x720 and 1280x720). I absolutely agree with you guys on stretching, which looks really awful. I don't do it normally, but for HD games I make exceptions for.

By the way, Using Fielddeinterlace(blend=false, dthreshold=0), I get nearly what I'm going for. A decent deinterlacing without any artifacts left behind, but since the threshold is 0, I get jagged lines. This is acceptable, if only it didn't have the jagged edges and such.

Blaze_Heatnix
29th December 2011, 06:38
Ok then, I've taken what nhope said about trying QTGMC.

SetMemoryMax(512)
SetMTMode(3, 2)
avisource("test.avi")
SetMTMode(2)
LoadCplugin("C:\Program Files\AviSynth 2.6\plugins\yadif.dll")
import("C:\Program Files\AviSynth 2.6\plugins\QTGMC-3.32.avs")
QTGMC(preset="super fast", tr2=3)
converttorgb32
crop(0,0,-2,-4)
#trim(97,97)
lanczosresize(1280,720)
sharpen(.2)
ConvertToYV12()
import("C:\Program Files\AviSynth 2.6\plugins\LSFmod.v1.9.avs")
LSFmod(strength=600, edgemode=1)

Now I have it like this because it says QTGMC can run in YUY2 colorspace (my video is YUY2 by default, so no need for conversion), but everytime I try to import it in Virtualdub to test it out, it says "mt_makediff: unsupported colorspace...can only run in YUV colorspace." I don't want to converttoyv12 so early because, as I have said before, deinterlacing in that colorspace is absolutely not wanted.

TheSkiller
29th December 2011, 14:36
LSFmod() is the problem, it does not work with YUY2 unfortunately. Your video will end up in YV12 anyway so actually you do not lose anything by adding ConvertToYV12() before LSFmod().


Well you guys, remember, I'm not trying to acheive the aspect ratio of my recording. I want the aspect ratio of PS3 footage (with which I'm upscaling would be iirc somewhere between 1080x720 and 1280x720). Ah, I've just had a look at your sample. It seems everyone including me assumed your captured video to be a 4:3 recording. It's a 16:9 one (yes, you've said it actually ;)). 984x720 is not a frame size related to the captured one (which uses non-square pixels), it is the correct resolution to scale the captured video to if your PS3 was setup to output in 4:3 SD.

Looking at your sample there is something that looks odd which could be potentially an error regarding the chosen capture resolution: nearly all of the 720 horizontal pixels actually carry picture. I have never captured off a PS3 so I cannot say if the PS3 does indeed output a picture like that (which would be non standard NTSC) but chances are that your correct capture resolution should be 704x480.
What do you use to capture the video?

-Vit-
29th December 2011, 15:34
For YUY2 make sure you read the fine print on QTGMC:
"For YUY2 input you must use mt_masktools-25.dll. Although not strictly 'correct' mt_masktools-25.dll can be used with SEt's Avisynth 2.6MT for multithreaded usage."

Blaze_Heatnix
29th December 2011, 19:10
LSFmod() is the problem, it does not work with YUY2 unfortunately. Your video will end up in YV12 anyway so actually you do not lose anything by adding ConvertToYV12() before LSFmod().

Wait, that's exactly what I'm doing (see above post).

What do you use to capture the video?

I use a Dazzle DVC 100. It's one of the finer SD capture devices I can think of. Also, you tend to learn alot more by capturing from... just about any video game console actually, since they produce sometimes very different results to what people are used to, at least from my experiences.

For YUY2 make sure you read the fine print on QTGMC:
"For YUY2 input you must use mt_masktools-25.dll. Although not strictly 'correct' mt_masktools-25.dll can be used with SEt's Avisynth 2.6MT for multithreaded usage."

Ah yes, that was the problem. I can't believe I zoned over that text, how silly of me. Right then, all I need to do is import mt_masktools-25.dll.

I guess that about does it for QTGMC. I just have to hope my PC doesn't explode when I go to encode :P

So for the record, there really isn't a deinterlacing filter that deinterlaces as flawlessly as assumetff().separatefields().lanczosresize(width,height).assumeframebased(), right? Of course, by flawlessly, I mean it's a perfect doublefps deinterlacing method with no interlacing artifacts left behind, even though it shrinks the video vertically to fit each field.

Gavino
29th December 2011, 20:00
So for the record, there really isn't a deinterlacing filter that deinterlaces as flawlessly as assumetff().separatefields().lanczosresize(width,height).assumeframebased(), right? Of course, by flawlessly, I mean it's a perfect doublefps deinterlacing method with no interlacing artifacts left behind, even though it shrinks the video vertically to fit each field.
That method is far from flawless.
Because odd and even fields have different vertical alignment, the result will appear to bob up and down on each frame.

Blaze_Heatnix
29th December 2011, 20:30
That method is far from flawless.
Because odd and even fields have different vertical alignment, the result will appear to bob up and down on each frame.

Yes of course, but I mean aside from the bobbing. I also work with older video game footage. If you simply use assumetff().separatefields().lanczosresize(width,height).assumeframebased() on say, a NES, Genesis/Megadrive or SNES (among other things), you would get perfect 60fps with no bobbing. But yeah, all in all, I just wanted to make sure that there wasn't something similar to such usage in another filter besides the more powerful filters such as MVbob or QTGMC.

TheSkiller
29th December 2011, 21:36
Wait, that's exactly what I'm doing (see above post).Sorry, I must have overlooked it. Please post script snippets using the [code] tags, it makes it easier to read.

I use a Dazzle DVC 100. (...) Also, you tend to learn alot more by capturing from... just about any video game console actually, since they produce sometimes very different results to what people are used to (...)
I know, I have captured off different consoles myself but not from any current generation consoles (well, once off a XBOX360 via composite, and everything was as expected). It just makes me wonder, the native horizontal capture resolution of all the Dazzle products should be 720, so it digitizes a scanline length of 53.333µs. A valid NTSC video signal however has a scanline length of 52.655 (711 pixels) so yeah, it seems the PS3 outputs an odd signal.
I guess it's not too surprising though, the PS1 and PS2 used wrong timings as well for both PAL and NTSC (yes, that's the dirty truth).

So for the record, there really isn't a deinterlacing filter that deinterlaces as flawlessly as assumetff().separatefields().lanczosresize(width,height).assumeframebased(), right?
There is, it's a simple Bob() which is built into AviSynth. It does exactly what you want. But it's "dumb", lots of up/down bobbing.



By the way, if you want to preserve the pixelated look of retro game footage, use PointBob() to bob-deinterlace them (part of the MVbob package). It's like Bob() but uses point interpolation which keeps that pixelated look. As you have discovered already, there is no up/down bobbing with that type of footage.

Blaze_Heatnix
29th December 2011, 23:32
Sorry, I must have overlooked it. Please post script snippets using the [code] tags, it makes it easier to read.

Ah, yes I'll keep that in mind, sorry.

There is, it's a simple Bob() which is built into AviSynth. It does exactly what you want. But it's "dumb", lots of up/down bobbing.



By the way, if you want to preserve the pixelated look of retro game footage, use PointBob() to bob-deinterlace them (part of the MVbob package). It's like Bob() but uses point interpolation which keeps that pixelated look. As you have discovered already, there is no up/down bobbing with that type of footage.

Thanks, I'll keep that in mind as well. I guess that about does it for me then. Thanks you guys for the help. I would have never guessed I'd end up using QTGMC after all, heh. :)

Gavino
30th December 2011, 01:20
There is, it's a simple Bob() which is built into AviSynth. It does exactly what you want. But it's "dumb", lots of up/down bobbing.
There's no up/down bobbing with Bob (despite its name), as it takes the vertical field alignment into account. However, it is dumb in the sense that it has no temporal element and so loses resolution and introduces 'shimmer' on stationary scenes.

TheSkiller
30th December 2011, 11:59
Yes, it's that shimmer that I meant when I said "bobbing". ;)
If you apply Bob() on a detailed static scene you will find that the picture is jumpy, bobs, shimmers...