PDA

View Full Version : minimum vertical crop for intelaced in xvid?


george_zhu
16th February 2004, 20:13
The vertical size for interlaced YV12 is x4. In the new faq, nic said xvid always works with 16x16 block. Do I need to keep the interlaced video has vertical size with x16 mutipler or x32 mutipler?

manono
17th February 2004, 00:46
Hi-

You're talking about cropping interlaced video (or the AviSynth pages that discuss it are). Nic is talking about resized video. You should resize to mod 16. Here's one of the pages that discusses the cropping requirements:

http://www.avisynth.org/index.php?page=Crop

george_zhu
17th February 2004, 03:04
Well, it semms that there are some understanding problem. For example, I have 480x480 interlaced footage with some bottom garbage lines. I would like to encode them into Xvid. Actually those garbage are about 6 lines. As YV12, the closest number is 8. However, what Nic said made me feel there is no gain with this 480x472. I should crop 16 lines instead. But if the macroblock is 16x16 and within a field. The minimum lines I should cut would be 32. I am not sure whether my reasonning is correct. Please confirm me if it is right or correct me.

Thanks.

Originally posted by manono
Hi-

You're talking about cropping interlaced video (or the AviSynth pages that discuss it are). Nic is talking about resized video. You should resize to mod 16. Here's one of the pages that discusses the cropping requirements:

http://www.avisynth.org/index.php?page=Crop

manono
17th February 2004, 03:57
Hi-

Well, it semms that there are some understanding problem.

Not on my end, there's not. If you have 6 pixels of garbage, then you crop 8 pixels from the bottom. But, you're right in saying that 480x472 is a bad resolution. You have to resize. And you'll have to crop more from the left and right sides to maintain proper AR. So one way to do it is:

Crop(4,0,-4,-8)
LanczosResize(480,480)

Or you add back some black at the bottom to replace the pixels you took out:

Crop(0,0,-0,-8)
AddBorders(0,0,0,8)

That way you don't crop any from the left and right sides. But I much prefer the first way. All this assumes that 480x480 is the correct 1:1 resolution. Maybe you have to resize to 640x480. I don't know.

george_zhu
17th February 2004, 15:33
Well. 480x480 is the SVCD res. I capture the footage from camcorder and basically make two copies, one SVCD for TV and the other with xvid for archive(same size 40min/CD but more detail).

I think resize will hurt the quality more than just put the letterbox cover the garbage line, isn't it? Then next qustion is how to make the xvid as efficient as possible. If I crop 32x32, xvid will definitely gives higher quality because it works with less macroblocks. However, it seems no gain in quality for 8-line crop because it is smaller than a macroblock. How about 16 lines? Will that be one less macroblock in interlaced video?

BTW:I do not care AR in it since WMP Classic can change it in any way.

manono
17th February 2004, 18:59
Hi-

Are you actually thinking of encoding it as interlaced? Both the SVCD as well as the .avi? Not a good move in my opinion. You need a much higher bitrate for the same quality when encoding interlaced material. Why don't you try a good deinterlacer, like KernalDeInt, and make the whole thing progressive? I can almost, but not quite, understand keeping it interlaced for SVCD playback on a TV set, but certainly not encoding the XviD as interlaced. I understand that it doesn't work very well anyway.

But anyway, to answer your question, a pixel is a pixel, whether it's from a field or a frame. So cropping by 16 pixels will then allow you to encode whole macroblocks. You don't have to crop away 32 pixels. But, personally, I wouldn't crop into the picture anymore than necessary. I'd prefer to resize to a correct AR any time.

I think resize will hurt the quality more than just put the letterbox cover the garbage line, isn't it?

I don't know. If you resize in the .avs, or you resize on playback, what's the difference? It still gets resized. I much prefer to resize before encoding so I don't have to mess with it later on. And it won't have that annoying black bar on the bottom. Heck, even the SVCD gets resized again on playback, since you're encoding at a 4:3 DAR.

If I crop 32x32, xvid will definitely gives higher quality because it works with less macroblocks.

Fewer macroblocks because you cut out a lot of the video. Maybe that's not important to you. I don't know. For the SVCD you still have to make it 480x480. Maybe you plan on doing that by adding back more black. For the .avi, you'll have fewer macroblocks, but you'll also have less detail when you watch it full screen, or through a DVD/MPEG4 player. It'll look more smoothed or blurry. Fewer macroblocks doesn't necessarily translate to higher quality. Would you consider 320x240 as having better quality than 640x480? By your definition it should since it has 1/4 the macroblocks. Me, I can't stand to watch low resolution video. But do it anyway you like. It's not my video.

george_zhu
18th February 2004, 00:23
Thx firstly. Well, it raises some confusion I always have.

1. What should I do for SVCD?

The highest res I can capture is 720x480. For a final SVCD 480x480. What is the way to conserve most quality? (i)capture at 720x480->edit(trim, reorder)->resize to 480x480->encode with CCE, (ii) capture at 480x480->crop the bottom->edit-> risize to 480x480->encode (iii)->capture at 480x480->letterbox the bottom line->encode?

Or should I deinterlace it and then encode? I think deinterlace will degrade quality (more or less). Since I will watch it on TV, interlace is no problem for view. Next problem is that whether Encode program like progressive video? Will the progressive mode has higher efficiency and therefore can yield higher quality?

2. Xvid and macroblock.

I guess my question is more like this: for a 16x16 macroblock in a interlaced video, will they all from one field or will they have 8 line in upper field and 8 lines in bottom field?

3. quality
Since encoding is the way to lost details. I think crop-> encoding preserve more detail than crop-->resize-> encoding provided we want same final bitrate file (for example 40 min/CD).

manono
18th February 2004, 17:51
Hi again-

1. I've never captured anything in my life, but it seems to me that capturing in the highest resolution possible without dropping frames will give you the highest initial quality and detail. And cropping and resizing afterwards will then give you the highest possible final quality and detail. So I would go with (i). There is a case that can be made for adding black bars on all 4 sides to account for the TV set's overscan (you won't see the added black bars). So you might consider something like:

LanczosResize(448,448)
AddBorders(16,16,16,16)

That's the way I do my 4:3 DVD to SVCD conversions. There are fewer video pixels to encode, and it'll result in higher quality for a given bitrate. Of course, the black bars require fewer bits to encode.

In the case of your captures where you want to cut 6 pixels from the bottom, FitCD gives me:

Crop(6,0,708,474)
LanczosResize(448,448)
AddBorders(16,16,16,16)

As for deinterlacing, of course deinterlacers aren't perfect, but there are some very good ones, and, again, I recommend KernelDeInt. I've read that keeping the footage interlaced requires around 50% higher bitrate to maintain the same quality when compared to progressive encoding. Or put another way, for the same bitrate, keeping it interlaced will result in something like 1/3 less quality (I think). So yes, encoding as progressive gives you (much) higher efficiency, to use your words.

2. Again, the encoder doesn't care if a horizontal line of pixels is from a field or a frame (except how it affects the encoding efficiency). If it's interlaced, then yes, the 16x16 macroblock will consist of 8 top fields and 8 bottom fields.

3. Yes, I think that you're probably correct that cropping without resizing results in somewhat better quality. I also think that the difference is so slight as to be negligible, and certainly not noticeable to the eye.

george_zhu
18th February 2004, 18:49
Thank you very much. I learned a lot.

Only one thing I do not completely agree. I learned that actually what the capture card did in horizontal line is to get large number of samples (>>720) and resample it to the resolution we set. So I think if we do not need to apply filter on it, capture at the final-result resolution is the better way since one-resample seems to be better than two resample(capture card+software avisyth or vdub).

Thanks for your comment on interlace. One more question: is you comment about interlace's quality comparision apply to both mpeg2 and mpeg4? If that is true for both, I should have deinterlace in both cases.

Originally posted by manono
Hi again-

1. I've never captured anything in my life, but it seems to me that capturing in the highest resolution possible without dropping frames will give you the highest initial quality and detail. And cropping and resizing afterwards will then give you the highest possible final quality and detail. So I would go with (i). There is a case that can be made for adding black bars on all 4 sides to account for the TV set's overscan (you won't see the added black bars). So you might consider something like:

LanczosResize(448,448)
AddBorders(16,16,16,16)

That's the way I do my 4:3 DVD to SVCD conversions. There are fewer video pixels to encode, and it'll result in higher quality for a given bitrate. Of course, the black bars require fewer bits to encode.

In the case of your captures where you want to cut 6 pixels from the bottom, FitCD gives me:

Crop(6,0,708,474)
LanczosResize(448,448)
AddBorders(16,16,16,16)

As for deinterlacing, of course deinterlacers aren't perfect, but there are some very good ones, and, again, I recommend KernelDeInt. I've read that keeping the footage interlaced requires around 50% higher bitrate to maintain the same quality when compared to progressive encoding. Or put another way, for the same bitrate, keeping it interlaced will result in something like 1/3 less quality (I think). So yes, encoding as progressive gives you (much) higher efficiency, to use your words.

2. Again, the encoder doesn't care if a horizontal line of pixels is from a field or a frame (except how it affects the encoding efficiency). If it's interlaced, then yes, the 16x16 macroblock will consist of 8 top fields and 8 bottom fields.

3. Yes, I think that you're probably correct that cropping without resizing results in somewhat better quality. I also think that the difference is so slight as to be negligible, and certainly not noticeable to the eye.

manono
18th February 2004, 19:19
Hi-

I learned that actually what the capture card did in horizontal line is to get large number of samples (>>720) and resample it to the resolution we set.

Oh, is the camcorder's native resolution 480x480? Then you're right. There's no point in capturing at a higher resolution. Did you say that somewhere? If so, I either missed it or forgot it. Sorry. But I do think that it's good to capture at the camcorder's resolution, if it's higher than 480x480. But since I don't capture anything, and since I didn't really understand that sentence of yours that I quoted, then you can ignore me. You seem to be saying that the capture card can't get the footage unchanged from the camcorder. Do you even need it in this case? Can't you use a USB or Firewire connection to get the footage to your computer? Or maybe the camcorder is analog and you have to convert to digital. This is something about which jggimi and many others know much more than I.

is you comment about interlace's quality comparision apply to both mpeg2 and mpeg4?

I'm not going to be much help there either, as I've never encoded anything as interlaced. Even for SVCD, I prefer to encode progressive frames, and then to apply pulldown if necessary. It wasn't even possible, until very recently, to encode MPEG4 as interlaced. But my belief is that the deinterlacers available in AviSynth are better than those in a software player or even in almost all DVD/MPEG4 players. But if you're asking about the comment that you need 50% higher bitrate when encoding as interlaced, then that was referring to MPEG2, but I think it also applies to MPEG4 .

george_zhu
18th February 2004, 19:48
hehe. I captured from a Hi8 anolog camcorder with a capture card. And Hi8 is 400 vertical lines if I remember it correctly and it does not make much sense to talk about horizontal res for an anolog signal. Then I think my sentence makes more sense in this context.

And for interlace stuff, I think at least my DVD player (not progressive one) and TV (not HDTV) play the interlace video naturally. So there is no issure for player to deinterlace. And that is the reason I want to encode in interlace mode.


Originally posted by manono
Hi-

I learned that actually what the capture card did in horizontal line is to get large number of samples (>>720) and resample it to the resolution we set.

Oh, is the camcorder's native resolution 480x480? Then you're right. There's no point in capturing at a higher resolution. Did you say that somewhere? If so, I either missed it or forgot it. Sorry. But I do think that it's good to capture at the camcorder's resolution, if it's higher than 480x480. But since I don't capture anything, and since I didn't really understand that sentence of yours that I quoted, then you can ignore me. You seem to be saying that the capture card can't get the footage unchanged from the camcorder. Do you even need it in this case? Can't you use a USB or Firewire connection to get the footage to your computer? Or maybe the camcorder is analog and you have to convert to digital. This is something about which jggimi and many others know much more than I.

is you comment about interlace's quality comparision apply to both mpeg2 and mpeg4?

I'm not going to be much help there either, as I've never encoded anything as interlaced. Even for SVCD, I prefer to encode progressive frames, and then to apply pulldown if necessary. It wasn't even possible, until very recently, to encode MPEG4 as interlaced. But my belief is that the deinterlacers available in AviSynth are better than those in a software player or even in almost all DVD/MPEG4 players. But if you're asking about the comment that you need 50% higher bitrate when encoding as interlaced, then that was referring to MPEG2, but I think it also applies to MPEG4 .