PDA

View Full Version : Anamorphic resizing


chipzoller
16th February 2007, 18:56
@blutach
The one sure way to determine this (and I'd trust the ripper) is to open the rip in PgcEdit, go to the main movie, right click and select Domain Stream Attrributes. This will tell you if it is 16:9 or 4:4 with hard matte.
This is the post I was referring to in my PM.

I'd like to re-open this and ask about proper anamorphic resizing. I've spent several hours reading various digests and tutorials about anamorphic and widescreen, namely:
http://www.dvdfile.com/news/special_report/production_a_z/anamorphic.htm
http://gregl.net/videophile/anamorphic.htm
http://en.wikipedia.org/wiki/Anamorphic

But would like to see if this method yields lowest quality loss and most correct intended AR. If a DVD says Widescreen (2.35:1) but enhanced for 16:9, the 2.35:1 is an indication of it being anamorphic, correct? And assuming I want to rip and encode the movie resizing back to the intended AR, is the most acceptable and lowest quality loss method to just do 720x304? Using this AR (closer to 2.36:1) only introduces a slight bit of AR error while still maintaining the mod16 dimensions. Basically, I understand the theory behind anamorphic and displaying it properly on TVs, but I'm mainly interested in how to resize this back to proper display ratio.

Bascially, I think it works something like this:

The image below is a direct capture from the DVD stream, which is 720x480. It contains black bars already encoded (and thus taking up space on the disc with this info.) in order to be compatible with fullscreen TVs (this part I'm not 100% sure about why exactly they are encoded directly into the frame)
http://czoller.myweb.uga.edu/orig.png

The next image is the same frame from the DVD but cropped to remove the encoded black bars. After this is cropped, the effective 'active' area of the picture we're concerned about is 716x358 (2:1 AR)-still not correct as you can see it's stretched on the vertical.
http://czoller.myweb.uga.edu/cropped.png

The final image below is then resized back to its intended display aspect ration of 2.35:1 resizing on the vertical to 716x304.
http://czoller.myweb.uga.edu/correct.png

So in short I ask you, is my logic correct in this process and for a full-resolution encode of the title is this final frame resolution correct in maintaining optimal quality while restoring the movie back to its intended resolution?

thanks for any help.

Turtleggjp
16th February 2007, 19:09
I think I have seen this before. It looks like the 2.35:1 movie has black bars added to make it 16:9 (1.77778:1). It is then encoded at 720x480 anamorphic 16:9. I think the most proper way to do this would be to resize the 720x480 to a 16:9 resolution (720x405 I believe) and then crop out the black bars that are left. Whatever this resolution is, should have the movie in its proper shape. The only problem is that when you resize video with black next to it, some of the edge pixels may get blended with the black. What I've done from here is noted this resolution, then gone back to the 720x480 size, cropped the black bars from there, then resized the video to the resolution I found earlier. This would hopefully eliminate the blended edges.

Matt

chipzoller
16th February 2007, 19:14
Well, this is my weekend project: to fully understand ARs and encoding/resizing the various ones.

Turtleggjp, if what you say is correct about resizing with black bars then cropping blurring edges, then is the method I outlined above "better"? Better aside, should my method also produce a correct frame shape?


EDIT: And likewise if the DVD says 1.85 widescreen (for which both IFOedit and PGCedit report 16:9 letterbox) and after cropping black areas from the left and right side of the frame it becomes 704, then the best vertical size would then be 384 to maintain as little AR error as possible while still maintaining mod16. Would this be considered "full correct resolution" to the resized frame? Or would this be the highest correct resolution given the DVD source resolution of 720x480?

chipzoller
16th February 2007, 19:57
Thanks for reminding me of that. After reading through it again I noticed one thing:

So the 720x480 stream will be stretched horizontally to 853x480 during playback. This allows to use the full vertical resolution of the DVD which retains maximum quality.

My reasoning was with the opposite dimension. I was assuming to keep maximum DVD quality that you would keep the full horizontal resolution (after cropping) and resize the vertical.

Is one better than the other? What is common practice for retaining maximum quality?

IanD
16th February 2007, 20:32
I've spent most of my Christmas vacation archiving my dvd collection to a media server using ripit4me with Decrypter and FixVTS. I'm up to 150 movies and counting, but have stumbled on several movies that say they are 16x9 but the ripping software says they are 4x3, what gives? BTW some say "with black bars" so those I understand, but others appear to be anamorphic, yet they also rip as 4x3...

I notice that when I play these back (using Media Player Classic) the window that my MPC displays is indeed 4x3 but the image of the actual movie inside this frame is 16x9.

Can someone enlighten me? Also, once I start playing these movies back on my 16x9 HDTV, I'm concerned about formatting. How will these movies appear on my tv? WIll I be able to stretch the actual movie image to fill my 16x9 display area on my tv?

Thanks!

brad
The basic standard DVD frame is 720x480 (for NTSC) or 720x576 (for PAL). There are other "standard" resolutions, but for the purpose of this exercise, we will concentrate on this basic standard.

Unlike HDTV, HD formats or other video formats (e.g. divx) where the frames are sized to suit the actual image, DVD always uses 720x480 or 720x576, regardless of how much of the frame is occupied by actual image and so may have some part of the frame wasted with useless black pixels.

Within this frame, the image can represent full-screen (i.e. fills a 4:3 aspect TV screen), letterbox (i.e. the image occupies a band across the 4:3 screen with black bars of varying widths above and below depending on the image aspect ratio) or anamorphic (i.e. the letterbox image is stretched vertically to occupy more of the frame so that a 16:9 movie occupies the full frame and other aspect ratios have varying sizes of upper/lower black bands: this stretch is unsqueezed on playback).

The first 2 options (full screen or letterbox) are flagged as 4:3 and designed to display on a 4:3 TV with the correct aspect ratio. The 3rd option (anamorphic) is flagged as 16:9 and designed to display on a widescreen TV with the correct aspect ratio.

It is up to the player and display device as to how the frame is scaled for display.

When output to a 4:3 TV, the first 2 options are output unchanged, whilst the 3rd is either scaled to letterbox or a 4:3 portion of the widescreen image extracted from the centre.

When output to a widescreen TV, the first 2 options have black bars applied on the sides, whilst the 3rd is stretched horizontally to fill the screen width (thus restoring the correct aspect ratio).

There may be additional zoom options on the player and TV to provide more flexibility in displaying letterbox on a widescreen TV. In theory, zooming in on a letterbox frame should enable filling the full widescreen TV width (instead of having black bars all round the image).

Some DVD cases say 16:9, when in fact the movie frame is actually letterbox and not anamorphic. A letterbox DVD (with a movie aspect of 16:9) would display in MPC as a 4:3 window with a 16:9 band of movie inside it. It is generally unreliable to go by what is printed on the DVD case as there does not appear to be a widespread standard adopted within the industry to describe the formatting of the content and much different terminology is used. Hopefully though, the aspect ratio flagging on the disc will be correct, but even this can not always be guaranteed and I have seen a few examples where the wrong flagging was applied.

It is possible to use Ifoedit to modify the .ifo files in a DVD structure to change the aspect ratio flagging if it is incorrect. DVDs are flagged as either 4:3 or 16:9 and then additional 4:3 Pan&Scan or letterbox "hints" are also provided to assist the player in scaling those formats depending on how the image is actually constructed within the frame.

How the 3 DVD aspect options will appear on your HDTV is dependent on the abilities of your player and TV zoom functions.

chipzoller
16th February 2007, 20:34
I've also noticed for one of my discs that Widescreen 1.85:1 is printed on the back cover, yet it gets displayed as 16:9 widescreen. Why is this? Which DAR is correct here as there's no DAR flag for 1.85:1.


EDIT: I understand what's going on here. The camera captured the film at a ratio of 1.85:1 yet because this isn't a standard AR value, when the DVD was produced, they letterboxed or added black bars around the picture to produce a frame AR of 16:9 even though the active area is still 1.85:1. At least I think this is what's going on :)

r0lZ
17th February 2007, 08:14
Your edit is right. The movie has been filmed in Cinemascope, and no TVs have the proper aspect ratio to display it without black borders. Therefore, it is necessary to letterbox the image in a 16:9 frame. Hence the black bars. This is also why PgcEdit reports it as 16:9. Being an IFO editor, it cannot know the original AR of the movie, but only the AR of the encoded video frame, including the black bars.

I fully agree with the explanations of Turtleggjp and IanD above. But note that you have to take the pixel aspect ratio of the target display into account when you resize the image. The pixel AR is (usually) 1:1 on a PC monitor, but is different on a PAL and NTSC TV. The method explained by Turtleggjp assumes you do not change the target device, and is therefore suitable only if you want to display the movie on a NTSC TV.

chipzoller
17th February 2007, 14:39
@r0lz, thanks for your response, however could you look at my 3 previous posts and tell me your impressions? I'm particularly interested in which axis to keep and which to resize; to do as Doom9's guide suggests and keep the vertical but resize larger on the horizontal, or vice versa.

But note that you have to take the pixel aspect ratio of the target display into account when you resize the image.

I'm assuming a PC in all these instances, but I think I understand his point that for display on a TV via a DVD player, you just have to resize the frame to a 16:9 rez and not correct for the anamorphic properties. The device should "unsqueeze" it on playback, at least this is what I understand. I could be wrong.

cc979
17th February 2007, 15:00
@r0lz, thanks for your response, however could you look at my 3 previous posts and tell me your impressions? I'm particularly interested in which axis to keep and which to resize; to do as Doom9's guide suggests and keep the vertical but resize larger on the horizontal, or vice versa.



I'm assuming a PC in all these instances, but I think I understand his point that for display on a TV via a DVD player, you just have to resize the frame to a 16:9 rez and not correct for the anamorphic properties. The device should "unsqueeze" it on playback, at least this is what I understand. I could be wrong.

regarding the AR stretching, the human eye is more sensitive to the vertical - that's why it's better to stretch horizontal

r0lZ
17th February 2007, 17:23
IMO, the choice of resizing horizontally or vertically depends again of what you want to do.

If you plan to display the resized material on a TV, it is better to have exactly the number of scanlines supported by the TV (ie 480 or 576) as the hardware vertical resize introduces usually visible artifacts, and can create watered effects. Also, on analog TVs, the number of lines is really fixed, but the number of pixels per line is only a convention. You can freely change it. (This is why the DVD standard supports several horizontal resolutions (720, 704 and 352) but only one vertical resolution per video standard (480 or 576.) This consideration is especially important if your source material is interlaced.

Of course, if you want to display the material on a monitor or a digital TV, do not take my explanation into account. I have never heard that the eye is more sensible to the vertical dimension, but it's possible.
Anyway, you should take another fact in consideration. If you want to reencode to a relatively small file, it is better to reduce the image, as it gives usually better results than compressing more a larger image. But if disc space doesn't matter, I suggest enlarging the width.

The formula to resize Cinemascope for a display with 1:1 pixels is very simple: multiply the (real) height by 2.35 to compute the width, or divide the width by 2.35 to compute the height.

Note that some codecs require an height (and also sometimes the width) being a multiple of 8, 16 or even 32! So, you might be forced to crop the image a little bit before encoding!

chipzoller
17th February 2007, 19:23
r0lz,

If you want to reencode to a relatively small file, it is better to reduce the image, as it gives usually better results than compressing more a larger image. But if disc space doesn't matter, I suggest enlarging the width.


Let's say for example that I'm shooting for 1 CD rips (~710MB for overburn) and that everything less than or equal to 2 hours 20 minutes will be encoded with this amount in mind and that the source material is anamorphic, you suggest down-sizing the resolution rather than keeping it at max size (again, either keeping the vertical rez. and stretching on the horizontal or vice versa) in this case?

This is a bit off topic, but I was under the impression that encoding at a larger frame size would ultimately yield a higher picture than encoding the same material with a smaller frame size (but obviously still a correct AR) and letting the software player (again, all this with computer software players and monitors assumed) stretch upon full-screen playback.

r0lZ
17th February 2007, 19:29
Putting more than 1.5 hour on a CD is difficult without loosing quality. So, yes, I suggest reducing the image. An half resolution is really better than full-res badly encoded.
IMO, 720x306 is still a bit too large for a good compression.

chipzoller
17th February 2007, 19:34
Is it important to mention that I have x264 in mind as a compressor with everything turn on/up to the max? Wouldn't that determine or allow a higher than usual frame size?

r0lZ
17th February 2007, 19:40
I suppose so, but honestly, I haven't used that compressor yet. I prefer to copy the DVDs on DVDs! ;)

chipzoller
17th February 2007, 19:56
Ok, well let me see if I have this down and I'll leave you alone :)

If I take a DVD source that after cropping the frame size is 720x358 (which indicates it's stored as anamorphic widescreen based on these cropped only dimensions???), then to return to a FULL resolution as it would be displayed on a widscreen TV (meaning, if I'm not mistaken, that it must be stretched on the horizontal) the final encoded resolution would be something like 840x358?

So the cropping and resizing portion of the script would just be:
crop( 0, 60, -0, -62)
BilinearResize(840,358)

Am I on the right track here?

525/60
17th February 2007, 20:29
PAR is a ratio which explains how much each pixel needs to be stretched; it is independent of the starting frame and the destination frame.

720x480 --> 16x9 yields a PAR of (480·16)÷(720·9)=32÷27=1.185

Yet according to from the DVDFAQ by Jim TaylorFor anamorphic video, the pixels are fatter. Different pixel aspect ratios (none of them square) are used for each aspect ratio and resolution. 720-pixel and 704-pixel sizes have the same aspect ratio because the first includes overscan. Note that conventional values of 1.0950 and 0.9157 are for height/width (and are tweaked to match scanning rates). The table below uses less-confusing width/height values (y/x * h/w).

720x480 720x576
704x480 704x576 352x480 352x576
4:3 0.909 1.091 1.818 2.182
16:9 1.212 1.455 2.424 2.909

Two things jump out at me from this:
1) there is no PAR of 1.185,
2) the proper pixel aspect ratio corresponds to

704x480 --> 16x9 yields a PAR of (480·16)÷(704·9)=40÷33=1.212

The same thing works for PAL. That is, the easiest way to resize is to clip to a width of 704 from 720 and then resize to the proper DAR (16:9 for anamorphic; 4:3 for regular). The discarded video content can't be viewed on an interlaced TV anyway because it is in the overscan. Interestingly, if you author your DVD 704 pixels wide, you get the exact same aspect ratio and you see the exact same amount of picture when viewed on the telly. Of course, I know this is not what you are doing, but my point is that what can't be seen on the TV anyway can't be a critical loss.

Knowing that the exact PAR is 40:33 allows you to fudge in the right direction, for instance, applying a par of 40:33 to the 2:1 ratio frame yields a ratio of 80:33=2.42. So now I know that anything between 2.35 and 2.4 is an acceptable fudge factor.

In your case, I would have clipped to 720x360 (2:1 AR) and then resized to 720x304 (720x300 is more accurate, but then you lose the multiples of 16) or clip to 704x360 and resize to 768x320 or for spot-on accuracy clip to 704x480 and resize to 768x432 and then clip to 768x320.

OK, so in your case, if you want to make it smaller than what I just suggested above, clip to 704x480 and resize to 704x396 and clip to 704x288. clip, resize, clip is the only way to get spot-on accurate results; its the factor of eleven from 704 that throws a monkey wrench into the works.

I'm not saying it makes any practical difference if you are perfectly accurate or not. My point is to clear up the common misconception that 720x480 --> 16x9 equalin a ratio of 1.185 is the proper PAR for anamorphic NTSC DVDs; it's not. Also I am pointing out that a movie that has a DAR of 2.35 can be more accurately resized to a 2.4 DAR; this I first noticed with the movie 'Matrix'. (again, clipping to 720x360 gives a 2:1 AR multiplied by a 40:33 PAR yields a 2.42 DAR)

I know this is getting long, but maybe I can respond to the websites cited above where appropriate?

Regarding the Wikipeadia article, I like to use the term Scope also and agree that the proper DAR is 2.4 (stretch a 2.35 movie it to a 2.4 DAR if you clip off the matting first), but skip to the 'DVD video' section to understand how the term anamorphic applies to DVD. 'The World's Easiest Explanation' neither confirms nor contradicts my observation since it does not spend a lot of time discussing the 720x480 pixels that are stored on a DVD. It focuses on DAR but not PAR. Again, DVDFILE.COM 'What the Heck is Anamorphic DVD?' sticks strictly to a discussion of DAR, not PAR. PAR is what you need if you want to convert the PAR from the DVD to the 1:1 ratio PAR of your computer screen.

Finally, my earlier suggestion to resize up to 768x320 for a scope picture will maximize, in my experience, the resolution of the picture. In general, stretching one dimension while squeezing the other preserves maximum detail while maintaining sharpness. Stetching it as wide as 864 or 960 as in 720x360 --> 960x396 or 720x480 -->960x528 clipped to 960x400 or (using a PAR of 1.2 instead) 720x360 --> 864x360 maintains maximum resolution.

These are the maximum resolutions, but if you maximize sharpness instead of the total resolution, as in 768x320, it scales better for full screen viewing. Using a PAR of 1.2 gives a simple resize ratio or 6:5 which will also help to maximize sharpness and detail. It is also vastly easier than struggling with the correct PAR of 40:33 with its nasty factor of 11 to deal with and it can also be seen as a compromise between the correct ratio of 1.212 and the more commonly used ratio of 1.185, since no one seems to notice the error of the latter, why not use the simpler 1.2 ratio?

Stephen

chipzoller
17th February 2007, 22:25
Stephen, thanks for the response but I feel I'm getting more confused. Can you at least tell me what you think about my previous post? I want to keep it simple for as long as possible here.

525/60
17th February 2007, 23:08
@chipzoller
My previous post took me 4 hours to write, so I missed your discussion with r0lZ.

@r0lZ
Our use of the term PAR are not in harmony.

@all
I haven't addressed the thread directly yet, so here goes.

@chipzoller
So the 720x480 stream will be stretched horizontally to 853x480 during playback.
This implies a PAR of 1.185 which is the common misconception I spoke of.

So your script should look like this instead:crop( 0, 60, -0, -62)
BilinearResize(872,358)orcrop( 8, 60, -8, -62)
BilinearResize(840,358)Both imply the exact same PAR, but a different DAR.

But as previously stated, a compromise PAR of 1.2 might yield the best results due to a sharper scaling factor.crop( 0, 60, -0, -60)
BilinearResize(864,360)I also switched to a mod 16 frame to accomodate the MPEG macroblocks.

For the sharpest possible picture that resizes to full screen better, go a little smaller withcrop( 8, 0, -8, -0)
BilinearResize(768,432)
crop( 0, 56, -0, -56)And for better compressioncrop( 8, 0, -8, -0)
BilinearResize(640,360)
crop( 0, 48, -0, -48)It cuts the top and bottom off a little and is not mod 16 but mod 8, yet it uses the most accurate PAR of 1.212.

I have experimented with re-sizing for the computer a lot, although now I am concentrating on DVD and VCD instead of Divx. For VCD, I might use the codecrop(8,0,-8,-0)
ReduceBy2
to keep the aspect ratio of the original.

Have a nice day.

Stephen

chipzoller
17th February 2007, 23:35
Stephen, thanks again for your answer, but perhaps you should look at my last and most enlightened post (http://forum.doom9.org/showthread.php?p=955761#post955761) that concurs with your last post and code:crop( 8, 60, -8, -62)
BilinearResize(840,358) except I didn't crop on the left and right sides because that contains picture information and not black pixels.

For the code you posted, lets assume I did crop 16 pixels off the horizontal, this would leave me with a cropped frame size of 704x358, which would still mean to achieve the least amount of aspect ratio error while upholding a mod8 resolution I'd have to resize to 840x358.
Can someone at least address this post and #15 (above) to make sure I'm correct thus far?
I appreciate all the help and advice I can get!

525/60
17th February 2007, 23:54
@chipzoller

Sorry, again I missed your post while posting my own. But I think I am making it clear enough by giving you some concrete examples using the AviSynth scripting language. A scripting language is nicely unambiguous.

I tried to explain how I derived the NTSC PAR of 1.212 and did cite a good authority backing me up with the DVDFAQ by Jim Taylor.

The way you apply the PAR is by multiplying the starting AR by the PAR to get the DAR as in 1.5 times 1.212 equals 1.818 which in terms of exact ratios is:

720x480 times 40:33 equals 20:11

to see the relationship with what you know, let's express it like this:

704x480 times 40:33 equals 16:9

So you see, on a computer, the correct target for anamorphic video is 20:11 instead of 16:9, because on the TV the two sides are cut off due to overscan. This applies to both NTSC and PAL even though the PAR for PAL is different:

704x576 times 1.455 equals 16:9

Both NTSC and PAL have the same scan line length and nearly the same speed. The difference is that the refresh rate for PAL is a little slower which gives it more time to scan more lines for each frame. This is because the framerate is synced to the frequency of the alternating currnet (AC). In PAL countries, the frequency of AC is 50 Hrz and in NTSC countries, AC is 60 Hrz. It is really interlace fields per second, but I am focusing on the relative difference: PAL has more time to write more scan lines for greater resolution per frame, but a slower frequency for video. For Film it effectively has a higher frequency as well as a higher resolution, but then the trade off is that NTSC can store more minutes of Film for the same data rate. For video, the same data rate will yield an equal amount of minutes on DVD.

Stephen

525/60
18th February 2007, 00:11
@chipzoller
I will be very brief:crop( 8, 60, -8, -62)
BilinearResize(840,358)The above code is wrong:( :(
crop( 8, 60, -8, -62)
BilinearResize(872,358)THIS is right:D :D

A PAR of 1.185 will leave your avi slightly too narrow. The correct PAR is 1.212 which correlates to:

704x480 times 1.212 yields 16:9 or 1.778

But it is not necessary to crop the sides:

720x480 times 1.212 yields 20:11 or 1.818

So 20:11 is the proper DAR for anamorphic DVD on your computer.
872:480 is approx. equal to 20:11.
872:720 (1.211) is close to the ratio 40:33 (1.212).

Stephen

chipzoller
18th February 2007, 01:44
Well, I'm all but totally confused right now. I was hoping this wouldn't drag into a discussion of pixel aspect ratios because I don't fully understand proper resizing much less pixel ratios. But I desperately want to learn how to do something so simple as cropping and resize correctly yet each post confuses me further.

(sigh) let me try to pull my dumb ass out of the clouds here. Please bear with me and I apologize I seem so utterly dense. I'm really not.

Stephen, you say this is correct:
crop( 8, 60, -8, -62)
BilinearResize(872,358)
Just for clarity's sake when I go back and spend the 12 hours necessary to re-read this thread tomorrow, the process for this cropping and resizing does the following: Crops 720x480 to a resolution of 704x358 thereby removing overscan (I think). The resizing produces an end frame of 872x358 which has a DAR of ~2.44 (rounded to the closest hundredth).

But then you say 720x480 times 1.212 yields 20:11 or 1.818. I interpret this to mean that ONLY with anamorphic widescreen content, to find the proper display aspect ratio (DAR) on a computer you multiply the DVD aspect ratio (720/480=1.5) by the correct pixel aspect ratio (PAR) that you said is 1.212 to get 1.818.

And before this you state OK, so in your case, if you want to make it smaller than what I just suggested above, clip to 704x480 and resize to 704x396 and clip to 704x288. clip, resize, clip is the only way to get spot-on accurate results; its the factor of eleven from 704 that throws a monkey wrench into the works. But this end DAR is 2.44

I know that PAR is an important consideration, but we can't manipulate that; all we can do is alter the shape of the video frame size and thereby altering the pixel shape. So while PAR is important but behind-the-scenes info., our end consideration must ultimately be the frame aspect ratio. So the way I see it is PAR directly influences DAR.

I know you've spent a lot of time responding in this thread and I hope eventually people that have the same problems will be able to refer to this (maybe even as a sticky?). But is there some way you can really explain concretely for an idiot (at the time being) like myself? I'm literally pulling my hair out trying to comprehend this stuff yet I get balder with each successive post. What do you think, should I just shut up, not think so hard, and use the same code for each source? I don't mean to cause undue pain and a waste of anyones time :( :stupid:

525/60
18th February 2007, 04:15
In case all the numbers I am throwing around are confusing, here are my recommendations in order of decreasing resolution:

#PAR 1.211
crop( 0, 64, -0, -64)
BilinearResize(872,352)#PAR 1.2
crop( 0, 64, -0, -64)
BilinearResize(864,352)#PAR 1.212
crop( 8, 0, -8, -0)
BilinearResize(768,432)
crop( 0, 56, -0, -56)#PAR 1.212
crop( 8, 0, -8, -0)
BilinearResize(640,360)
crop( 0, 48, -0, -48)Here is a frame from the Matrix movie in the original AR followed by the resized versions of the same frame.
6800

6801

6802

6803

6804
The main point of these attachments is to demonstrate how little the slight cropping of the 'active area' affects the result. The correct AR renders the skewed perspective more forcefully, I think. 'Dodge this.'

Stephen

chipzoller
18th February 2007, 04:30
Thanks. I'll save these and do some tests soon. But could I also beg you to look at my last post (#22) and put some of those things to rest when you have a chance? I want to understand the concepts behind your suggestions but need to clear up a few inconsistencies in my mind first.

EDIT: Also something else I wanted to ask. Would it perhaps be easier to just go from the DVD resolution and crop any black bars, then set the 2.35 AR in the container (AVC in MKV for example)?

r0lZ
18th February 2007, 04:36
In the past, when I encoded my movies in XviD, I have written a little tool to compute easily the target resolution for any pixel aspect ratio. It might be useful. You can download it here (http://download.videohelp.com/r0lZ/pgcedit/third_party/r0lz/ResCalc.zip).

You have to enter the source pixel aspect ratio and image dimension, the target pixel aspect ratio and the eventual constraints of the encoder. Don't worry, there are presets. Then, use the slider to find a good target resolution, with the minimal error.

There is also an advanced mode, but don't ask me how it works! I haven't used this program since a while!

chipzoller
18th February 2007, 05:01
r0lz, thanks so much! I think this will come in very handy at least until I emerge from my idiot state :)

One confirmation question about its usage relating to anamorphic:

If you're trying to compute the best resolution (lowest AR loss) with anamorphic, for the source resolution you have to determine the frame size AFTER cropping the black bars from the top and bottom, correct? If it's normal 16:9 widescreen you just go ahead (since the vertical rez. is not matted)?

I've attached 4 files from 2 different DVDs I have. The first is "Dr. No" (1962) and is not anamorphic (right?) from the first pic, which is the original unresized from the DVD. The second I've cropped the right and left sides and correctly(?) resized to 768x432 which introduces no AR error(?).

The last two pics are from "For Your Eyes Only" (1981) and shows the first unresized and straight from the DVD while the second shows the black bars cropped from the top and bottom and resized to 800x328 which only introduces 0.05 of AR error.

Can you please tell me if my math and judgment is best (or at least correct)? Do I understand this correctly?

525/60
18th February 2007, 08:18
@chipzoller
Your specifically mentioning the overscan made me notice my mistake:crop( 8, 60, -8, -62)
BilinearResize(872,358)The red is wrong, there is no need to crop the sides if you stretch it that much.

The math is:
720 times 1.212 PAR equals 872.72crop( 0, 60, -0, -62)
BilinearResize(872,358)is what I meant, as I wrote in my subsequent post.

It bothered me that I did find a low resolution resize that does not crop the sides. Initially, I thought the wide DAR of 2.5 was unacceptable, but that is not the case:LanczosResize(640,352)
crop(0,48,-0,-48)
This works very nicely, as the attachment verifies:6812
Basically, I do not think it is important to get AR perfectly. What bothers be is the mistaken notion that causes most people to derive a PAR of 1.185 instead of the correct PAR of 1.212.
The quote that I find just plain wrong is:So the 720x480 stream will be stretched horizontally to 853x480 during playback.853÷720=1.185 PAR
Properly 720·1.212=872
So the quote should have been:So the 720x480 stream will be stretched horizontally to 872x480 during playback.However, if you play that on an interlaced TV, only 853 worth of each line will be visible, the rest will be lost in overscan. Still, you have to stretch it that much to get the proper AR on a computer screen, where you can see the whole line and where there is no overscan. That is a run-on sentence of course.

Bear in mind that the pixels on a TV are not square. 704x480 gets squished into a 4:3 DAR without any resizing on a TV, but on a computer the 704x480 frame must be resized to 640x480 due to the computer 1:1 AR.

Regarding post 22, I have already explained my mistake with the resize. Yes, I have been discussing only anamorphic, although a parallel problem arises for non-anamorphic: The proper DAR for 720x480 DVD is 15:11, not 4:3; the PAR is 10:11. So what is the proper DAR for a 704x480 DVD?

Stephen

525/60
18th February 2007, 08:25
@chipzoller

Regarding your post 26, I am not going to respond for now, because I think you will catch your mistakes as you take the time to read more and think it through tomorrow (today, I mean next).

Stephen

blutach
18th February 2007, 09:18
Guys,

In order to get attachments quickly displayed and not wait for us to come along, you might consider www.imageshack.us

Regards

r0lZ
18th February 2007, 11:19
If you're trying to compute the best resolution (lowest AR loss) with anamorphic, for the source resolution you have to determine the frame size AFTER cropping the black bars from the top and bottom, correct? If it's normal 16:9 widescreen you just go ahead (since the vertical rez. is not matted)?Right.

The first is "Dr. No" (1962) and is not anamorphic (right?) from the first pic, which is the original unresized from the DVD. The second I've cropped the right and left sides and correctly(?) resized to 768x432 which introduces no AR error(?).I assume the source is 4:3, not anamorphic, but it is difficult to be sure with the image you have posted.
Not sure what you did, but I have those values:
Pixel AR: I've selected "NTSC 4:3 - 10:11" from the dropdown list, which gives 0.909090909091.
I've used 708x480 as the resolution.
I assume a target square pixel AR of 1.
With a constraint to blocks of 16x16 (not sure it's what you need), I obtain a final resolution of 592x448 (error is 1.47%, negligible.) This is really a 4:3 image, with a minimal error. We can verify that easily, as the target pixel is square. The horizontal resolution must be approximately 1.33x the vertical one. 592/4*3=444. That's correct.
Obviously, you don't have the same thing at all. Have you assumed a 16:9 movie?

The last two pics are from "For Your Eyes Only" (1981) and shows the first unresized and straight from the DVD while the second shows the black bars cropped from the top and bottom and resized to 800x328 which only introduces 0.05 of AR error.
In this case, I use the NTSC 16:9 - 40:33 (1.21212121212), 720x360 for the source. No change in the target. For a width of 800, I obtain 336 for the height, with an error of 1.82%. 800/2.35 = 340. Again, it's a very minimal error.
IMO, a better resolution is 704x288 (error 0.83%), or, if you don't want to resize horizontally, 720x304 (2.36%).

Note that the target pixel aspect is exactly square on a PC monitor for the resolution 1024x768 (1024/4*3=768) but not for 1280x1024 (as 1280/4*3 = 960, not 1024) but it is good practice to consider the pixel as square for a PC display. The difference is minimal anyway. If you want really square pixels, you have to use 1280x960.

chipzoller
18th February 2007, 14:19
@r0lz,
I assume the source is 4:3, not anamorphic, but it is difficult to be sure with the image you have posted.
Not sure what you did, but I have those values:
Pixel AR: I've selected "NTSC 4:3 - 10:11" from the dropdown list, which gives 0.909090909091.
I've used 708x480 as the resolution.
I assume a target square pixel AR of 1.
With a constraint to blocks of 16x16 (not sure it's what you need), I obtain a final resolution of 592x448 (error is 1.47%, negligible.) This is really a 4:3 image, with a minimal error. We can verify that easily, as the target pixel is square. The horizontal resolution must be approximately 1.33x the vertical one. 592/4*3=444. That's correct.
Obviously, you don't have the same thing at all. Have you assumed a 16:9 movie?
Yes, I assumed widescreen because this is a DVD that says widescreen format on the case. And just for testing purposes I resized to a 4:3 resolution assuming a true frame size of 704x480 and resized to 640x480 (so no AR loss) and it definitely does not look right. And that's another big question I had; How to tell the aspect ratio just by looking at the video stream itself?


In this case, I use the NTSC 16:9 - 40:33 (1.21212121212), 720x360 for the source. No change in the target. For a width of 800, I obtain 336 for the height, with an error of 1.82%. 800/2.35 = 340.Then we did the same thing only I used 720x328 (and cropped off 2 more pixels on the bottom than you did), but I think we're close enough.

I'm going to read the last few posts very carefully now...

r0lZ
18th February 2007, 15:03
I can't be sure it is 4:3 by looking at your image, as it is difficult to see if it is stretched vertically or not.
Usually, I use PgcEdit to examine the aspect ratio of the title domain. But you can also use any software player, and look at the size of the video window. (I mean the real window, including the black borders, if any.)

Note also that, in a DVD, the aspect ratio must be either 4:3 or 16:9 anamorphic. It cannot be something else.

Of course, there is also the possibility to have a 16:9 video letterboxed in a 4:3 container, with black borders. But for ResCalc, you have to give the pixel aspect ratio, which, in this case, is 4:3, even if the original movie is 16:9.

Anyway, if your movie is coded in 16:9, your calculation is right. 768x432 is correct. But you can also use, for example, 800x448, or, for a better compression, 544x304.

Your calculation for the second movie is correct. 2 pixels less can explain the little difference.

chipzoller
18th February 2007, 15:31
@r0lz
Usually, I use PgcEdit to examine the aspect ratio of the title domain.IfoEdit reports the title domain is 16:9 letterboxed, so I guess that settles it. Even if it didn't I can clearly see when resizing to 4:3 and 16:9 that the former is much distorted and therefore cannot be correct.

@all
I think I understand how best to go about determining correct aspect ratios now, but let me try and get you guys to tie up some loose strings I have by addressing them directly. You see, even though to yourself what you may be saying makes sense, to someone else who doesn't see it that way it may not make sense at all. So let me pose these questions directly and hope for a direct response:

I earlier asked How to tell the aspect ratio just by looking at the video stream itself? to which r0lz responded there is only 4:3 or 16:9 coding of pictures, which I understand. What I had to realize is that this is only the DVD encode FRAME and NOT the actual active picture information. Anamorphic is encoded within a 16:9 frame, but the active picture information is not 16:9, it's just that we must use the PAR of 16:9 to restore it to its correct DAR. The way I saw this was like the following: xyzMovieReal -> 16:9 encoded frame=xyzMovieStored | xyzMovieStored -> 16:9 decoded=xyzMovie Real. If this makes sense I'm not sure, but what I realized is that a movie, regardless of it's active frame captured from the camera, coded in a certain AR must be returned via that AR to achieve the correct end-result look.

So in summary, the end dimensions of an encoded anamorphic frame should be closer to 2.4 AR than 2.35. This is what I've gathered from all these posts.

r0lZ
18th February 2007, 17:34
A final note:
I have already seen several commercial DVDs where the original image aspect ratio was not respected at all. The movie was cropped! (This is normal in pan & scan DVDs, but when they precise that the original dimensions are respected, they should not crop the image at all!)
Furthermore, due to human errors, the pixel aspect ratio might be wrong also.
Therefore, use the rules with caution. It might be necessary to compensate those errors. Your eye is the final judge.

Also, note that the "letterboxed" flag displayed by IfoEdit (and PgcEdit) doesn't mean that the movie has black borders in the DVD. This flag instructs the player of what it must do when a 16:9 anamorphic image is displayed on a 4:3 TV. When the letterbox flag is set, the player must shrink the image vertically and add black borders to build a 4:3 image, compatible with the old TVs. When the Pan&Scan flag is set, it must zoom in the image, and crop the left and right borders. When both flags are set, the user preference (configured via the player menu) takes precedence. At least one flag must be ON. Usually, the pan&scan flag is used only in menu domains.

On the other hand, there is also an "already letterboxed" flag for the 4:3 mode. (I think it is called "top and bottom cropped" in IfoEdit.) When this flag is set, the player must send a signal to the 16:9 TV to tell that the image is not really a 4:3 image, but rather, a 16:9 image already letterboxed in a 4:3 container, with black horizontal borders. The 16:9 TV can therefore automatically zoom in the image to display it full screen. Of course, that's not at all 16:9 anamorphic. Unfortunately, very few TV and/or players support that.

In your second James Bond above, the Cinemascope movie is letterboxed in a true 16:9 anamorphic container, and a 16:9 TV cannot zoom further, as the image occupies already the full width. This is not an "already letterboxed" 4:3 image.

525/60
18th February 2007, 20:41
even if the original movie is 16:9
@r0lZ
16:9 is not a move aspect ratio, it is a television aspect ratio.

A movie can be in that AP if there are no matte bars above and below, but it probably was cropped to fit the DVD widescreen standard. "Dr. No" is a good example of a DVD that isn't coded for picture information in the overscan area at each side. This makes sense since that part of the image can't be seen on an interlaced TV anyway. I think it is anamorphic and your right, it can't really be determined from that picture.

Stephen

chipzoller
18th February 2007, 20:41
I'd also like to ask a small yet specific question about detecting 16:9 formats: Is the definitive way to know if a DVD source is widescreen or anamorphic (both have 16:9 flag encoded) is to merely look at the raw DVD resolution (720x480 in my case) and see if there are black bars encoded on top and bottom versus just a stretched image (and therefore no black bars on top or bottom)?

A movie can be in that AP if there are no matte bars above and below This is what Dr. No looks like. How could it be anamorphic in this case? And if it can't be determined in the screen shot from the source DVD, how else would you tell?
Well, I played the DVD back in PowerDVD to see how it would render, and based on the prog. setting the window size and capturing a frame from it, it captured 768x432 or 16:9. Doing the same thing with VLC captured a shot of 853x480 (also 16:9). So does this determine it is NOT anamorphic?

Borbus
18th February 2007, 21:21
I'd also like to ask a small yet specific question about detecting 16:9 formats: Is the definitive way to know if a DVD source is widescreen or anamorphic (both have 16:9 flag encoded) is to merely look at the raw DVD resolution (720x480 in my case) and see if there are black bars encoded on top and bottom versus just a stretched image (and therefore no black bars on top or bottom)?

No. It can still be 16:9 anamorphic AND have black bars. 16/9 = 1.78:1 so if the AR is higher than this (e.g. 1.85, 2.35 etc.) then it will still have black bars.

I find simply looking at a DVD at it's OAR (720x576 or 720x480) enough to decide if it's 16:9 or 4:3. I am used to PAL DVDs though, it may be easier to tell with PAL than with NTSC.

chipzoller
18th February 2007, 21:25
It can still be 16:9 anamorphic AND have black bars. Well this is what I mean :) If it's 16:9 anamorphic then it WILL have thick black bars on top and bottom. If it's simply widescreen it will either have none or much thinner ones (like the one DVD I had that was shot in 1.85:1 and letterboxed to reach 16:9)

525/60
18th February 2007, 21:27
@chipzoller
You are looking at the problem from the wrong end. The DVD standard is defined in terms of how the image on the DVD is viewed on two types of TVs, regular 4:3 AP TVs and 16:9 widescreen TVs. The difference between them is a ratio of 4:3rds as well (the square of 4 is 16 and the square of 3 is 9). This is how the aspect ratio in a DVD is defined. Furthermore it is defined that the equivalent of 702 pixels by 486 pixels in the digital domain will be viewable on a TV. (I started to say 'regular TV', but I then realized the same is true for both regular and widescreen). Because TVs are analog and not digital, there are no pixels on a TV screen. The image from a non-anamorphic DVD does not need to be resized to attain the correct aspect ratio on a regular TV and the image on an anamorphic DVD does not need adjustment of the AP on a widescreen TV, because (unlike a computer screen) the aspect ratio of a TV is not square. To play an anamorphic DVD on a regular TV, the player will skip every forth line and add black mattes above and below.

The 702x486 frame is changed to 704x480 to accomodate the MPEG macroblocks. The PAR is defined in terms of this 704x480 frame.

But you are doing something entirely different, you are learning how to resize the image for the 1:1 square ratio of your computer screen. The information above is necessary for you to understand how to do this, but it is still a different operation entirely. Just remember that a TV does not have a square aspect ratio like a computer screen does, so the image does not have to be resized for a TV except in the common case when you are playing an anamorphic DVD on a regular TV.

Nevertheless you can derive the PAR you need by solving for one of the following equations:

720:480 · ? = 16:9
704:480 · ? = 16:9
702:486 · ? = 16:9
for anamorphic

720:480 · ? = 4:3
704:480 · ? = 4:3
702:486 · ? = 4:3
for non-anamorphic

Once you have solved these equations in terms of a ratio (like for instance 10:11, 40:33, or even maybe 12:13), you will understand my scribblings. You should know that the middle equation is the proper DVD standard, the top equations (in each group I mean) are the commonly understood way to derive the PAR, and the bottom equations are theoretically how the image might actually be rendered on a TV screen in terms of the computer screen . In terms of an AviSynth Script that bottom anamorphic equation would look like this:Crop(0,64,-0,-64)
LanczosResize(880,352)
(I mean if you solve the equation and use the ratio found thereby to stretch the width, this is the script you would use.)

Stephen

r0lZ
18th February 2007, 22:56
@r0lZ
16:9 is not a move aspect ratio, it is a television aspect ratio.I mean a movie coded in 16:9. If you have followed my explanation, that should be obvious.

chipzoller
19th February 2007, 03:09
@525/60
Not to be rude, but could you address this question before launching into another technical page? :) I am determined to understand this as well as you, but in order to do so I have to take it in small spoonfuls.

Let me see if I have this correct:

You've been trying to tell me that because the PAR of a TV is different from the PAR of the computer, the aspect ratio of a DVD (whether designed for 16:9 or 4:3) must be different on a TV than on a computer. So something that is anamorphic widescreen on DVD will be displayed as 2.35 on a TV, but on a computer to reach the same "shape" it must be a different aspect ratio.

Also, what do you mean by "AP" above?


And how about if I did this to see if I can realize and apply correct resizing techniques (with correct PARs): Post VOB clips from about 3 various DVD sources along with statements about their capture and display properties along with crop/resizing scripts. Would one or both (or anyone else reading by now) of you be up to checking over my work?

525/60
19th February 2007, 07:32
@r0lZ
This is the part that threw me:
there is also the possibility to have a 16:9 video letterboxed in a 4:3 containerThe original movie wouldn't be in 16:9 AP, as I said, that is the widescreen TV AP. If a dvd formatted a movie in 16:9 AP, it would have to be an anamorphic DVD. I don't think I am taking anything you said out of context and I do respect your knowledge.

@chipzoller
AP means aspect ratio.

I am not launching into anything that isn't directly related to resizing DVDs for viewing on a computer. Sorry to say, I have no idea why I appear to be going off on a tangent to others.

There is no PAR for television; a DVD player feeds the TV the video stream straight into it without any resizing. A non-anamorphic NTSC DVD's data is stored exactly how a regular 4:3 NTSC TV needs it.

It's not apparent to you why I need to make that point, but trust me, it helps to clarify the discussion to understand that. We need to go over a little background just so we don't confuse our terms. There are too many aspect ratios: there is the aspect ratio of the data as it is stored on the DVD (there are two of those), and there is the 1:1 square aspect ratio of the computer screen, there is the aspect ratio of the TV screen and there is the ratio needed to convert the data on the DVD for the computer screen, which I call PAR for 'pixel aspect ratio'. There is no equivalent PAR for the TV, because the data on the DVD is designed for the TV and there is no conversion necessary.

According to a link you cited at the start of the thread and which I had assumed you read: 2.35 films are really shot in 2.39 aspect ratio starting from October 1970. Read: Anamorphic widescreen (http://en.wikipedia.org/wiki/Anamorphic#2.35.2C_2.39.2C_or_2.40.3F)

I don't mean to sound like a wiseguy, but I really assumed you had carefully read all the material in the links you posted at the start of the thread. I used those links as a starting point for my own posts. Here's another quote from that link:
With the exception of certain specialist and archivist areas, generally 2.35, 2.39, and 2.40 mean the same to most professionals, whether they themselves are even aware of the changes or not.
If a movie says it is 2.35 on the DVD cover, the proper display aspect ratio (DAR) for the 'active picture' part is 2.40 .

I studied ITU-R reccomendations for YV12, NTSC, and Broadcast TV as a background, but I am trying to stick to the technical information relating to resizing anamorphic DVD video for the computer screen, only.

Do you know that the word 'derive' means?
I ask because you might speak English as a second language.
Did you note what I said in my previous post?Once you have solved these equations in terms of a ratio (like for instance 10:11, 40:33, or even maybe 12:13), you will understand my scribblings.
So, let me show you what I mean.
I derive the correct PAR for anamorphic DVD by solving this equation thusly:

704:480 · ? = 16:9
? = (16 · 480):(704 · 9)
? = (1 · 480):(44 · 9)
? = (1 · 160):(44 · 3)
? = (1 · 40):(11 · 3)
? = 40:33
? = 1.212; <-- PAR!

Then sticking that PAR back into the formula:

720:480 · 40:33 = (720 · 40):(480 · 33)
720:480 · 40:33 = (240 · 40):(480 · 11)
720:480 · 40:33 = (240 · 1):(12 · 11)
720:480 · 40:33 = (20 · 1):(1 · 11)
720:480 · 40:33 = 20:11
720:480 · 40:33 = 1.818

This is how to use the PAR to determine the ratio of the frame you want to resize into. As in:Crop(0,0,720,480)
LanczosResize(20,11)As I demonstrated above, the PAR is the same for both 720x480 and 704x480, as stated at this site:
What's widescreen? How do the aspect ratios work? (http://www.dvddemystified.com/dvdfaq.html#3.5)

Reading this post and the two sites linked from this post will help everyone to understand my points. I promise.

Stephen

chipzoller
20th February 2007, 15:55
After some experimentation and re-reading your posts carefully I think I understand the relationship between PAR and DAR.

I didn't realize that the DAR may have nothing to do with the PAR.
Essentially, PAR is the "stretchability" of a given image in relation to the display device. So it seems to me that if we have a non-anamorphic movie that is flagged as 16:9, the PAR must be 1.212 but reinserting this into the equation yields 1.818 for the full frame AR (no matte cropping yet). Depending on the "active picture area" that the movie was shot in, cropping mattes away may yield a different AR but the same PAR since no stretching is occurring, only remove pixels, not reshaping them.


Would it be fine when resizing to resize the frame first, then crop the mattes? This way it may be simpler to determine the frame size based on the PAR and once resized, crop unneeded black pixels.

Also I was hoping you could clarify this assumption on my part:

There are two widescreen formats (I'm referring not to as stored on DVD but actual "active picture area" formats) flagged on DVD as 16:9 - "regular" widescreen and anamorphic. Is this so or am I mistaken?
Or if something is flagged as 16:9 on DVD then the content HAS to be anamorphic?

I know I started this thread with anamorphic in mind, but I want to broaden the scope now to include other types.

Stephen, thanks for your continual responses. I'll eventually understand this perfectly well with your help.

mpucoder
20th February 2007, 17:30
There are two widescreen formats (I'm referring not to as stored on DVD but actual "active picture area" formats) flagged on DVD as 16:9 - "regular" widescreen and anamorphic. Is this so or am I mistaken?There is only one 16:9 format, it is called anamorphic (but see next comment)
Or if something is flagged as 16:9 on DVD then the content HAS to be anamorphic?Yes and no. The term "anamorphic" refers to film and lenses, if the lens is non-spherical it is called anamorphic because the image on film is compressed in one dimension. Technically the word should not be used for digital images, and if it is used it should refer to images with PAR other than 1:1 (like avi and bmp). However the word is used to describe 16:9 on DVD because the image is compressed horizontally compared to a 4:3 image.

chipzoller
21st February 2007, 01:28
So for example, these two screen shots, although they appear on the DVD differently (matted vs. non-matted), they are both anamorphically shot (but flagged as 16:9)?

http://img136.imageshack.us/img136/1114/169anaps0.th.jpg (http://img136.imageshack.us/my.php?image=169anaps0.jpg)
http://img136.imageshack.us/img136/9096/169qt4.th.jpg (http://img136.imageshack.us/my.php?image=169qt4.jpg)

What terminology do I use to describe a distinction between the two? What are the differences? Perhaps I'm just ignorant of what to call these. The first shot is from "Fearless" (2006) and the second "Footloose" (1981).

525/60
21st February 2007, 02:03
Essentially, PAR is the "stretchability" of a given image in relation to the display device. Right ON!:)So it seems to me that if we have a non-anamorphic movie that is flagged as 16:9, the PAR must be 1.212If the DVD is flagged as 16:9, we call it an anamorphic DVD and its PAR must be 40:33=1.21212121..........(it is a rational number with a decimal that never ends). If the DVD if flagged as 4:3, it is non-anamorphic and its PAR is 10:11=0.909090...(on and on forever).but reinserting this into the equation yields 1.818 for the full frame AR (no matte cropping yet)'no matte cropping yet'? Yeah, That's right. Still --> The frame that you resize your image into is not the PAR, don't confuse them. Instead take the advice of the wise man who said this:I didn't realize that the DAR may have nothing to do with the PAR.Wait! That was you!;)

mpucoder was right in pointing out that the term 'anamorphic' has two meanings, the first is an anamorphic lens used for filming and the second is the DVD AP that compresses the image in a way similiar and analogous, but not precisely like how that lens compresses the image on film. The purpose of anamorphic is analogous too: to waste less space above and below the active image on the film or in the 720x480 pixels of stored image on a DVD. But never mind that, you need to either ignore the way images are recorded on film entirely or you need to study film well enough that you do not confuse the aspect ratio issues of film with the aspect ratios on the DVD (which are only two: 4:3 and 16:9).

Depending on the "active picture area" that the movie was shot in, cropping mattes away may yield a different AR but the same PAR since no stretching is occurring, only remove pixels, not reshaping them.Yes, but do you know how to apply the PAR properly?

Would it be fine when resizing to resize the frame first, then crop the mattes? This way it may be simpler to determine the frame size based on the PAR and once resized, crop unneeded black pixels.You are right, it is easier to resize first and then crop. But people resist this because then you are resizing area that you crop out later. And this wastes processing power. In particular: 1.818 refers to a resize without any cropping.

The formula for using par is to take the width divided by the height of the frame after cropping (or 720:480=1.5 if you do not crop first) times PAR (40:33=1.212 if the DVD is anamorphic). If you do not crop anything, and just resize, it looks like this:

720:480 x 40:33 =
(720 x 40) : (480 x 33) =
(240 x 1) : (12 x 11) = 20:11 = 1.818

LanczosResize(640,352)

But then, if the film was shot in 'Scope' with a nominal apect ratio of 2.35, you would reduce the height of the frame (when you chop off the black mattes above and below the active picture) enough so that the aspect ratio of the frame (width/height) would increase to 2.4 or more.

LanczosResize(640,352)
Crop(0,40,-0,-40)

Or you could crop it first the then resize to 2.4.

720:360 x 40:33 =
(720 x 40) : (360 x 33) =
(2 x 40 ) : (1 x 33) = 80:33 = 2.42424242...

720:357 x 40:33 =
(720 x 40) : (357 x 33) =
(80 x 40 ) : (119 x 11) = 3200:1309 = 2.44461420932

Crop(0,60,-0,-60)
LanczosResize(640,264)

OK, so in practice, it is even a little bigger than 2.4; that's fine, that's a consequence of using the PAR correctly, it is not wrong.

As you said 'pixel aspect ratio' tells us how much to stretch each pixel and is independent of the starting frame AP. For each starting frame AP, there is a unique target frame AP that the PAR tells us to resize into.

Finally, let me tell you that it is easier to start by ignoring the 'active picture/black matte' issue and just resize then cut. So therefore in response to the next quote:There are two widescreen formats (I'm referring not to as stored on DVD but actual "active picture area" formats) flagged on DVD as 16:9 - "regular" widescreen and anamorphic. Is this so or am I mistaken?

Ignore the film widescreen formats entirely and just concentrate on the two types of DVDs 4:3 and 16:9. Those two refer to the type of TV they are made to show their material on and not the type of film that is encoded on them. A widescreen TV is a 16:9 aspect ratio TV. As I said before, the ratio between the two aspect ratios is 4:3, that is 16:9 is four squared divided by 3 squared. 4:3 x 4:3 = 16:9.

So let's forget about cropping, let us pretend that we want to keep the full frame. If that were the case (it's not really, since you do not reallly want to encode the black mattes), there would be only two aspect ratios to resize into, one for each PAR, one for each DVD 4:3 and 16:9.

For a 16:9 DVD (we can stop using the term 'anamorphic' altogether. mpucoder is right, it is more properly used to refer to a type of film lens):

720:480 times 40:33 equals 20:11 equals 1.818.
Which equals also 640:352 and also 960:528 (try 720:396 too).

And for a 4:3 DVD (Let's decide for our purposes that these are the names of the two types of DVDs):

720:480 times 10:11 equals 15:11 equals 1.364.
Which equals 480:352 and 720:528 and also 630:462.

The factor of 11 makes these ratios difficult to work with, so I prefer to crop to something that allows me to cancel the factor of 11 out. (You should have a calculator in had as you read this.) For instance 704 has a factor of eleven, which makes that factor cancel out:

704:480 times 40:33 equals 16:9
Which equals 512:288 and 768:432.

But as anyone would tell you other than me, there is no need to be so exact. It doesn't have to be perfectly correct, only close.

I'm only being mathmatically correct for the purpose of these examples.

I do prefer to use the ratio 40:33 instead of the approximation to that ratio 1.212 on my calculator, but the difference is not crucial.

Or if something is flagged as 16:9 on DVD then the content HAS to be anamorphic? Yes, Hoorah, Hip Hip Hooray! That is 100% correct! If it's flagged as 16:9, that will tell you how to resize it to look right on your computer screen. On the packaging, if it says widescreen, that refers to the type of TV it's meant to be played on and not to the aspect ratio of the film, a 16:9 widescreen TV. With enough practice, you can learn to distingish the format of the film from the format of the DVD on the packaging, even thought the terminology is ambiguous, inconsistent, and just plain wrong;:mad:

I know I started this thread with anamorphic in mind, but I want to broaden the scope now to include other types.Again, I want to emphasize that there are only two types to choose from. There are many aspect ratios to crop to, but only two PARs.

I like this stuff *BECAUSE* it is a challenge to explain, but it really isn't hard to understand.

By the way, notice that these are exactly the same:

LanczosResize(640,352)
Crop(0,44,-0,-44)

Crop(0,60,-0,-60)
LanczosResize(640,264)

And I would prefer to change the height to mod 16, even though to do is I have to crop out part of the picture and change the aspect ratio of a 2.35 movie to 2.5:

LanczosResize(640,352)
Crop(0,48,-0,-48)

Crop(0,60,-0,-60)
LanczosResize(640,264)
Crop(0,4,-0,-4)

So do you crop first and then resize? It doesn't matter. And by the way the only reason I discuss the aspect ratio of the film is because it affects how much black matte border there is to crop off, not because it affects the aspect ratio of the DVD in any way. A 1.85 movie would have much thinner black mattes. (1.85 is called 'flat' aspect ratio and 2.35 is called 'Scope'.)

My first source of information on the technical aspects of DVDs was the DVDFAQ back nearly when it first came out. It was there that I noticed a fact that often goes unrecognized even by the most knowledgeable among us;)

Stephen

chipzoller
21st February 2007, 02:32
Stephen, continual thanks are in order for your detailed and informative posts. I'm going to read carefully.
But in the mean time, while you were working on your last post you must have missed my previous one. And for the time being I'm particularly interested in practical application to this theory.
See this: http://forum.doom9.org/showthread.php?p=958093#post958093

chipzoller
21st February 2007, 04:08
In response to your last post:

'no matte cropping yet'? Yeah, That's right. Still --> The frame that you resize your image into is not the PAR, don't confuse them.

I just wanted to confirm this. What I've finally realized is that while the PAR and frame AR (not sure how you get 'AP' to represent this but OK) they are related, the PAR is used to derive the correct DAR. And English is my first language, however knowing how to derive a value from an equation has little (if any value) if you can't relate this back into a functional perspective. Mathematics by itself means nothing until applied.

Yes, but do you know how to apply the PAR properly?
From reading (and re-reading, and re-reading) your informative posts the math makes sense and I now know how to apply the PAR. In a nutshell, this is my stumbling block that I think I've now demolished and I'll explain rationale:

I was trying to calculate proper DAR (at this point I didn't know of PAR) for the encoded frame, for example, 16:9 which as you know yields a value of ~1.778. In a world in which material was shot with a 1:1 PAR in mind, this would have been a fine and dandy value for an encoded frame's AR (nevermind mattes), however ~1.778 should NOT be the number for a DAR as stored on a computer--this is because the video (like the DVD spec. was designed to uphold) is encoded/stored with television in mind. When we take the DVD out of its natural environment (TV), we have to make certain compensations, the PAR adjustment being the most important of those compensations.
So we can set an initial frame size with the PAR and from there we can crop whatever we want...black mattes, skewed/defunct pixels, whatever...and come up with any DAR we want. But as long as the frame was initially sized (stretched, if you will) with this PAR in mind, any subsequent cropping that is done will not affect this value.

it is easier to resize first and then crop. But people resist this because then you are resizing area that you crop out later. And this wastes processing power.
Ah, I figured this would be the case. The only reason I asked is because you would have to be much more careful in considering the frame size after cropping. I haven't quite worked out in my head the correct process for ensuring the PAR is respected in resizing after a crop. What I'm thinking about in my head to make sure the resizing after the cropping doesn't obscure the PAR taken into consideration.


With enough practice, you can learn to distingish the format of the film from the format of the DVD on the packaging, even thought the terminology is ambiguous, inconsistent, and just plain wrong;
This is now what I'd like to transition into (see post #45, please) as I consider is the goal of this whole discussion (well, part of it). It was never my intention to involve any one person on this extended lecture for the purpose of learning how to resize 1 DVD at a time, regardless of the format. I remember a saying something like "Give a man a fish and you've fed him for a day. Teach a man to fish and you've fed him for a lifetime." Well I'm learning how to fish, but at present my reel keeps backlashing on me (if anyone here fishes) :)

And by the way the only reason I discuss the aspect ratio of the film is because it affects how much black matte border there is to crop off, not because it affects the aspect ratio of the DVD in any way.
&
you need to either ignore the way images are recorded on film entirely or you need to study film well enough that you do not confuse the aspect ratio issues of film with the aspect ratios on the DVD (which are only two: 4:3 and 16:9).
These, I think, are the most important statements I've come to realize. While I spent so much time trying to study and understand the different camera ARs they captured (read: 'active picture portion of the frame'), what I didn't realize was that all these could be encapsulated in black mattes and packaged as 16:9 on a DVD. This doesn't affect how to resize it as long as we still constrain ourselves to the correct PAR (40:33, or the less, albeit slightly, value of 1.2121). If we do resize it with this PAR in mind, then the mattes don't matter--even if you keep them--the playback will be correct in respect to its intended dimensions.

525/60
21st February 2007, 05:17
@chipzoller
And English is my first language, however knowing how to derive a value from an equation has little (if any value) if you can't relate this back into a functional perspective. Mathematics by itself means nothing until applied.I am a little offended that you think any math I presented doesn't apply directly to the problem at hand. I don't expect you to wade through anything that does not have value to you.

Way back at the beginning of the post, you used the wrong resize based on the wrong pixel aspect ratio. I have deomonstrated how people commonly arrive at the 1.185 aspect ratio resize, why it is wrong, and how to calculate (using math and solving equations, I thank you) the correct PAR and why it is the correct PAR.

Acually you wouldn't have so much trouble, if you focused on the task at hand, which is to make the image look right.

I was trying to calculate proper DARThe thing is you were so focused on how you were trying to do it and your own method that you didn't track very well with other peoples methods and how they think about it. Yes, in fact resizing is always a ratio, you want to stretch the width of the image 1.212 times as much as you stretch the height. But only for 16:9 DVDs, regular 4:3 DVDs require the width to be stretched less than the height by a 10:11 ratio.

In a world in which material was shot with a 1:1 PAR in mind, this would have been a fine and dandy value for an encoded frame's AR (nevermind mattes),Relax, it is all perfectly reasonable; its not hard. Film has no pixels, neither do televisions. The image is transferred digitally to the DVD as the television will read it.

however ~1.778 should NOT be the number for a DAR as stored on a computerNo, its a great DAR for storing on the computer:
crop(0,8,-0,8)
LanczosResize(786,432)

"Dr. No" (1962) and is not anamorphic (right?)I think it is anamorphic. Did you notice the the black bars at the sides? That is the part that wouldn't be visible on a TV. So cropping to 704x480 and resizing is the best method for that. Resizing is a ratio, not a number! Well, a ratio is a rational number.

The only reason I asked is because you would have to be much more careful in considering the frame size after cropping.Don't consider frame size after cropping. Just calculate the ratio between the width and the height. It can be any size, that is a separate matter.

It was never my intention to involve any one person on this extended lecture for the purpose of learning how to resize 1 DVD at a time, regardless of the format.In the future, when you post a question on a forum, you should be prepared to hear the answer. Meaning that you should put your preconceptions aside, and listen (or read) with an open mind.

While I spent so much time trying to study and understand the different camera ARsHey, I think camera ARs are fascinating. But DVD players can only read the information in the headers of the mpeg2 stream on the DVD, there are only two flags in that stream concerning aspect ratio: 4:3 and 16:9. End of story.

There are many other interesting aspects to this topic, but they can only mean something to you once you have got that in your head. Your job is to replicate what a DVD does, but adapt it for your computer screen. Since in one scenario, the ratio between the width of the frame to its height needs to be increased and in the other it needs to be decreased, it is very easy to spot the difference.

Stephen

chipzoller
21st February 2007, 13:18
I think it is anamorphic. Did you notice the the black bars at the sides?
Yes, although these are sidebars and not top/bottom mattes.
How about the two examples I posted in this post (http://forum.doom9.org/showthread.php?p=958093#post958093)? They are both anamorphically shot although one has mattes and the other doesn't?


No, its a great DAR for storing on the computer:

crop(0,8,-0,8)
LanczosResize(786,432)
Actually this resolution (1.8194) is closer to the desired 1.8181 than 1.778.

At present I'm trying to determine how to determine the desired frame size after cropping while still keeping the ratio the same. I'll have to post my thoughts and questions when I have a bit more time.

thanks again for your help with this!

EDIT:

Or you could crop it first the then resize to 2.4.

720:360 x 40:33 =
(720 x 40) : (360 x 33) =
(2 x 40 ) : (1 x 33) = 80:33 = 2.42424242...

720:357 x 40:33 =
(720 x 40) : (357 x 33) =
(80 x 40 ) : (119 x 11) = 3200:1309 = 2.44461420932

Ah, simple. I was thinking too much about this. Just determine crop values from the raw DVD frame size first and reduce that size by the cropped amount, then just multiply that by the PAR to come up with the DAR for the 'active' portion.

525/60
21st February 2007, 18:29
Actually this resolution (1.8194) is closer to the desired 1.8181 than 1.778.Yeah, but that's because I messed up. That would not look right. I just accidentally reversed two numbers. This is what I meant:
crop(0,8,-0,8)
LanczosResize(768,432)
It is helpful if you can double check my results, mainly by learning what this means:

704:480 · 40:33 = 16:9

Like everyone else (including very smart people who know that they are talking about), I thought that the following was true:

720:480 · 40:33 = 16:9

Meaning that for an anamorphic DVD, that is easiest way to resize to the whole frame to the television widescreen aspect ratio of 16:9. Of course the math doesn't work; they are not equal, but most people don't do the math:mad: But I did, because I wanted my resizes to be perfect:confused: Most people would say that is a waste of time, but in the long run, I learned something useful from it. So if you will indulge me, let me explain what I learned.

In the above equation, when you resize like this:
720x480 --> 16x9, there is an implied PAR that you are using whether you know what it is or not. You can find the PAR you are using by solving the equation. Then you can use the PAR to resize the same way even if you crop first. You see, we are starting with the assumption that that is the correct transformation, but we want to know the ratio of the resize we are using. We've come far enough along that we can see why this is an advantage, so you do already understand this. In order to find that ratio, I have to solve this equation (here we go with the math):

720:480 · ? = 16:9

? = (480 · 16) : (720 · 9)
? = (160 · 16) : (720 · 3)
? = (10 · 16) : (45 · 3)
? = (2 · 16) : (9 · 3) = 32:27 = 1.185

Meanwhile I am reading the DVDFAQ because I trust it completely. I still do. DVD Frequently Asked Questions (and Answers) (http://www.dvddemystified.com/dvdfaq.html) checkout this part: [0.3] Is this FAQ any good? Who wrote it? How do I know it's accurate? (http://www.dvddemystified.com/dvdfaq.html#0.3) So, I got to one of the good parts, a tricky part on a topic that confuses most of us: [3.5] What's widescreen? How do the aspect ratios work? (http://www.dvddemystified.com/dvdfaq.html#3.5)
At the bottom that that section is a table: 720x480 720x576
704x480 704x576 352x480 352x576
4:3 0.909 1.091 1.818 2.182
16:9 1.212 1.455 2.424 2.909Lookng at the table, the first thing I noticed was that there is no sign of the 1.185 which I calculated and was already using for my AVI files. I asked myself whether this 'pixel aspect ratio' as he calls it is the same thing I was calculating or not? And if so, why was I not getting the same result? The second thing I noticed was that, based on my assumptions, the table was doing something odd. Based on how I as calculating it, PAR would change depending on what the starting frame, as stored on the DVD, would be. All commercial DVDs store their frame information 720 pixels across, yet the legal DVD 704 pixel wide frames shared the same number in the table with the 720 pixel wide frames. In all other cases, each different frame size gets a different number. Is this PAR as I understood it, or not?

So what I did next was experiment with calculating PAR using the new 704x480 frame that this FAQ, which I trust, claims to be legal. This was very smart of me:rolleyes: Taking the time to make my own calculations led to an interesting discovery:

704:480 · ? = 16:9
? = (480 · 16) : (704 · 9)
? = (15 · 16) : (22 · 9)
? = (15 · 8) : (11 · 9)
? = (5 · 8) : (11 · 3) = 40:33 = 1.212

1.212 was in the table! This told me two things. That what I meant by PAR was the same thing that Jim was talking about in his FAQ. And that in all cases PAR was calculated using frames 704 pixels across or frames exactly half that size: 352 pixels across.

Why does this make sense? Because we know (some of us) that all you can view from the image on a DVD on an analog TV is the equivalent of a 702x486 pixel frame, which we round up and down for the DVD format to 704x480 to keep it all mod 16 (that is everything divides evenly into 16), so the extra width on the 720 pixel line will all be buried in the overscan and be invisible anyway. For the 704x480 frame, the DVD player must be padding both sides with blank overscan information to keep the picture in sync. Because the actual length of the line for both NTSC and PAL does need to be 720, but that includes about 9 pixels worth of overscan on each side which can't view on the TV screen whether the DVD has been encoded with picture information on those sides or not. Presumably the information can't be that important, since it can't be seen.

If the actual image viewable on a TV is closer to the equivalent of 702x486 pixels, wouldn't PAR be more accurately calculated like this?

702:486 · ? = 16:9
? = (486 · 16) : (702 · 9)
? = (2 · 16) : (26 · 1)
? = (1 · 16) : (13 · 1) = 16:13 = 1.231

Yes, it could well be more accurate, but according to the DVDFAQ and of course according to every other authority, it is not according to spec and presumably DVDs are encoded using the specifications so following the specifications to reverse the process should give you the most accurate result.

But notice the vast difference between 1.231 and 1.185. All these calculations have unearthed an important finding. 1.185 isn't just slightly inaccurate, but acceptable, it is so inaccurate as to be deemed wrong.:devil:

And if you want to stick with a method that is as easy as resizing to a 16x9 frame or a 4x3 frame depending of which type of DVD you have, then resize using the method I advocated at the beginning of this post:

crop(0,8,-0,8)
LanczosResize(768,432)crop(0,8,-0,8)
LanczosResize(640,480)

Also AP was another one of my mistakes, AP does not mean aspect ratio, it is AR. I just got into the habit of typing it wrong and I did not notice the error.

Stephen

PS

If this equation balances:

528:360 · 40:33 = 16:9

then this Avisynth Script would result in an image with a correct aspect ratio:

(Crop(96, 60, -96, -60)
Spline16Resize(640,360)

It would look the same as if you had enlarged a 2.35 movie on a widescreen TV enough to remove the black mattes.

Or try:

660:360 · 40:33 = 800:360 = 20:9 = 2.22

(Crop(30, 60, -30, -60)
Spline16Resize(800,360)

Stephen

chipzoller
21st February 2007, 18:51
Stephen, I haven't yet heard what you think of this post (http://forum.doom9.org/showthread.php?p=958093#post958093).

525/60
21st February 2007, 19:59
Stephen, I haven't yet heard what you think of this post.The reason I haven't responded is because we have already established that the presence of black mattes or no is completely irrelavant to the question of resizing. There are only two PAR for DVD and the mattes don't affect that PAR.

That leaves the question of terminology. If the film has a 2.35 AR and the DVD is anamorphic, then the black mattes will be 60 pixels in height approximately, but it varies slightly from film to film. The mattes are about 62 pixels high on the Matrix DVD.

Terminolgy:

There are two widecreen formats for film:

flat (1.85 AR) and scope (2.4 AR)

(As I pause to consider all the teminology, let me point out that I don't know what you want to know. Sometimes when you post a question on Doom9, no one will answer because they don't know what you're asking. You need to take responsibility to phrase your question in a way that makes it easy to answer the question you really want the answer to. If people don't respond to one of your posts, it can only be for one of three reasons: 1) no one knows the answer. 2) It is not clear what you really need to know (we don't know what you are asking) 3) It is so far off topic that no one is really interested (then you need to post to a different part of the forum or to a different forum entirely) For the last point, you are not supposed to double post, so you would need to ask the moderator whether he thinks his moving the thread to a different part the the forum would help.

OK, so we've got 'flat' and 'scope'. These aspect ratios are both called widescreen. Before widescreen talking movies were shot with an aspect ratio fo 1.375. Silent films had an aspect ratio of 1.33. Since the transition from silent film to talkies occured between the years 1928 - 1932, most movies not shot in widescreen were actually shot in an aspect ratio slightly larger than 4:3. So the apect ratios of 4:3 and 16:9 do not correspond to any films except silent picures from the 1920s. Instead, those are aspect ratios of television sets, standard and widescreen respectively. Notice that because 1.85 is not as wide as 2.35, some people people don't call it widescreen, but it is, its just that there are several different widescreen aspect ratios for film. 1.375 is the standard non-widescreen aspect ratio called Academy ratio (http://en.wikipedia.org/wiki/Academy_ratio) or "Academy Aperture".

So what is the difference between those two images?

I think the first is a film in 1.85 AR and the second is in 16:9 AR specifically produced for widescreen TV and not for film! Both images are clearly off a 16:9 AR anamorphic DVD.

16:9 is always for TV including the logo that the DVD plays before the logo that was part of the movie as it was originally shown in the movie theaters. You might not even get that first logo if you use DVDDecrypeter in IFO mode instead of FILE mode.

OK, maybe the whole movie is in 16:9 AR for Footloose, making what I am saying seem implausable. If that is the case, then the film was cropped to fit that AR. Read the Academy Ratio link, because it mentions briefly touches on every film AR. Although there are many of them, not one of them is exactly 1.78.

Stephen

Stephen

chipzoller
21st February 2007, 20:55
The reason I haven't responded is because we have already established that the presence of black mattes or no is completely irrelavant to the question of resizing.
Yes this is true, and I realize this. Maybe I should have been more precise in asking not the difference in handling/resizing the two, but the difference in the appearance of the two as shown in those raw frames.

You might not even get that first logo if you use DVDDecrypeter in IFO mode instead of FILE mode.
OK, maybe the whole movie is in 16:9 AR for Footloose, making what I am saying seem implausable.
Actually, at least with this movie the studio logo is part of the film and not in a separate PGC, but I know what you mean. Sometimes studio logos are separated on the DVD from the actual film feature. Footloose would then indeed be all 16:9, which as you say was cropped to fit that AR. In reading the Academy Ratio link you provided, I'm guessing Paramount matted the shot to a wider AR, then in the production of this DVD cropped away the matting in order to make it 'FOR' widescreen TV, unlike the first screenshot in which they took the whole film frame (with mattes) and made it "enhanced" for widescreen. In your estimation is this a correct or plausible observation?

525/60
21st February 2007, 21:44
I'm guessing Paramount matted the shot to a wider AR, then in the production of this DVD cropped away the matting in order to make it 'FOR' widescreen TV,Yes, that is exactly what I think too. I think they routinely do the same thing for 1.375 aspect ratio films too, cropping off the very little picture from the sides to make it conforn to 4:3 ratio or 1.36 ratio.

Stephen

chipzoller
22nd February 2007, 05:03
Well I now think I have a pretty good understanding of how to correctly handle these materials, which has piqued my interest even further. Tell me more! Or maybe point me in the direction of how matted anamorphic DVDs actually get displayed on 'standard' TV vs. widescreen. I did some reading that indicated x number of lines were dropped but don't know any specifics.
Taking those 2 screenshots as source material I'd like to know how each one is displayed on each TV kind. I'd gladly see myself and take some measurements if only I had a stand-alone DVD player.

And although this doesn't relate to this thread, the idea of crop after resize and the cpu time involved interests me. I wonder if the cpu time hit is significant since the pixels are basically zero-complexity and even after going through the encoder it probably doesn't waste too many cycles on those stagnant mattes. Even despite this, I'd still crop then resize, but maybe it would be better if I were to do some tests on my own.

525/60
22nd February 2007, 05:13
Tell me more! Be more specific than that. In fact, google, search for answers on this forum and when you hit an impass, ask a question.

Stephen

525/60
22nd February 2007, 05:22
I did some reading that indicated x number of lines were dropped but don't know any specifics.Remember I said the ratio between 4:3 and 16:9 is 4:3. The inverse of 4:3 is 3:4. That is how many lines are left when a DVD player adapts a 16:9 DVD to play on a 4:3 TV, three out of four. Then black mattes are added to the top and bottom. Its called letterboxing (http://en.wikipedia.org/wiki/Letterbox).

Stephen

mpucoder
22nd February 2007, 05:29
Couple random thoughts.

The reason the PAR is the same for 720 or 704 is that the pixel clock never changes, it is 13.5MHz.

Why does 720 exist? Easy, NTSC has a sligthly wider active area than PAL's 702, it works aout to about 711 pixels. The intent was to use 720x480 for NTSC and 704x576 for PAL.

Both 704 and 720 are multiples of 16, a very necessary requirement for mpeg with sub-sampled chrominance.

While overscan does exist in CRTs, modern displays do not need it (it exists to make picture shrinking caused by low power line voltage or poor voltage regulation on bright scenes less noticable) and can eliminate it, showing the entire picture.

525/60
22nd February 2007, 14:59
One thing we know for sure is that if you watched the DR NO movie on your TV, you would never see that the picture does not go all the way to the sides.

I'm sure mpucoder did not mean to imply otherwise, but NTSC and PAL have the same length of lines. They start each line using the same clock speed of 13.5 MHz as he said. They get in 720 pixels at that speed, not all of which are visible. We get into a debate on how much is not visible, but not all. The fact that some DVDs don't bother to write all the way to the edge is one indication of that.

PAL and NTSC write the lines at the same rate, but PAL has more time to write lines before it has to start at the top again. They start at the top at the same rate the electrical current alternates. So in PAL countries it alternates at a rate of 50 Hz which is slower than the 60 Hz AC of NTSC countries.

Stephen

mpucoder
22nd February 2007, 18:21
I'm sure mpucoder did not mean to imply otherwise, but NTSC and PAL have the same length of lines. They start each line using the same clock speed of 13.5 MHz as he said. They get in 720 pixels at that speed, not all of which are visible.That was my point, that the active area, ie the area unblanked in the analog signal, is different. For NTSC the line is 52.66.. microseconds (52.66 * 13.5 = 710.9), for PAL it is 52 microseconds (52 * 13.5 = 702). This is not, however, to accomodate overscan.

525/60
23rd February 2007, 01:12
@mpucoder
That was my point,Yeah, I know it was your point, but what I said might'd *APPEARED* to be contradicting you, but I wasn't.

Stephen

chipzoller
23rd February 2007, 01:16
EDIT: I asked before I did some independent reading. Topic clear.

525/60
23rd February 2007, 14:46
@chipzoller
What exactly is overscanHonestly, it isn't important.

You should consider encoding back to mpeg, then you can click 16:9 aspect ratio or 4:3 aspect ratio, scene detection, GOP size 12, pulldown or 3:2 pulldown depending on whether you use QuEnc or HCenc. Some players will play vob files. IfoEdit will play the vob file through the Ifo file. Some players will adjust the aspect ratio for you when playing mpeg files. But some won't. Using this method, you don't need to change the aspect ratio in the first place. So we don't want to get too far into this before we pull back and look at other options.

What player do you use to play back the files made from your DVDs? How do you encode the files?

Also you might consider starting a new thread before starting on a new topic, other people might be interested who won't read a thread on anamorphic resizing.

To wrap up this thread, I'd like to go back to the first post and discuss what aspect ratio you chose. I have no way to know how well you understand this stuff unless you give me an example.

Stephen

chipzoller
23rd February 2007, 15:20
What player do you use to play back the files made from your DVDs? How do you encode the files?
This whole thread was designed with PC archival and playback and the files encoded to x264 (MPEG-4 Part 10)

I'd like to go back to the first post and discuss what aspect ratio you chose. I have no way to know how well you understand this stuff unless you give me an example.

Ok, for example I'll take a true anamorphic (shot and stored as film) film. This is obviously flagged as 16:9 (with mattes encoded). I took the raw frame size (720x480) and determined crop values of:
crop( 8, 64, -8, -64)
Which then gives me a starting frame of 704x352. Since we know the PAR for converting to square pixels is 40:30 or ~1.2121, multiplying these two gives me a DAR of ~2.42. I then resize (after cropping) to a mod 16 size of 624x256 (~2.437) for which the aspect ratio error is less than 1%.
Do I pass the test?

525/60
23rd February 2007, 22:57
Do I pass the test?Yes, however that seems just the tiniest bit too small. 640x264 is exactly 80:33~2.42. If I want it be be mod 16 badly enough I could either crop even more down to 640x256 for the 2.5 AR which I seem to come back to over and over again (what is left of the picture is that much more enlarged within a relatively small file, so there's the trade off; if probably looks pretty good) or allow a small amount of black matting above and below the picture increasin the height relative to the width to 640x272. You can crop the sides off to make it fit in a 640x272 frame also. I'll show you the AviSynth script for the three different ways above to make it more clear.

Crop(8,64,-8,64)
LanczosResize(640,264)
Crop(0,4,0,-4)

Crop(8,64,-8,64)
LanczosResize(640,264)
AddBorders(0,4,0,-4)

Crop(8,60,-8,60)
LanczosResize(640,272)

OK, so it turns out that cropping less off the top and bottom allowed a closer approximation to 40:17 than cropping more off the sides does. The first example only increases the size of the picture by a ratio of 640:624 ~ 1.025641...

Do you have a particuliar player you like to use to play back your mpeg4 files?

Stephen

chipzoller
24th February 2007, 15:45
es, however that seems just the tiniest bit too small. 640x264 is exactly 80:33~2.42. If I want it be be mod 16 badly enough I could either crop even more down to 640x256 for the 2.5 AR which I seem to come back to over and over again (what is left of the picture is that much more enlarged within a relatively small file, so there's the trade off; if probably looks pretty good) or allow a small amount of black matting above and below the picture increasin the height relative to the width to 640x272. You can crop the sides off to make it fit in a 640x272 frame also. I'll show you the AviSynth script for the three different ways above to make it more clear.
Well like I said, 624x256 was the 'best' resolution that introduces the smallest amount of AR error for being a mod 16 resolution.

Do you have a particuliar player you like to use to play back your mpeg4 files?

I don't have any hardware player that will play AVC files. And I really don't know of any on the market yet, so I've been creating files that are profile-unrestricted and muxing in MKV for computer archival and playback.

r0lZ
24th February 2007, 17:01
I then resize (after cropping) to a mod 16 size of 624x256 (~2.437) for which the aspect ratio error is less than 1%.
Do I pass the test?That's exactly the values given by my calculator.
Anyway, take in mind that an error smaller than around 3% is totally unnoticeable.

chipzoller
24th February 2007, 17:06
Probably so, but since these are for computer playback (I'm still shooting for around 710MB muxed), I downsize them to around that resolution anyway, so why not TRY to be as precise as possible? And I thought I might add that reducing to this frame size and compressing with x264 on unrestricted profile will all goodies activated yields astonishing results on a 2hr. 5min. encode (with Nero AAC q=0.36 stereo audio). Its with these sizes that you can really see how advanced something like x264 is. It continually amazes me with quality at lower bitrates.

525/60
24th February 2007, 17:28
I don't have any hardware player that will play AVC files. And I really don't know of any on the market yet, so I've been creating files that are profile-unrestricted and muxing in MKV for computer archival and playback.I meant "How do you play them on your computer?". I was refering to software players.

I point out that my third example has slightly less AR error and size does matter. The other two have zero AR error, It's not necessary to have zero AR error, but again they are also bigger. It's a trade off; if you try to compress a really big image too much, it acctually looks worse than a smaller image that is well encoded. Still, you are losing a lot of detail at that size. 640 width is a popular optimal compromise between size and compressability. I suspect that the resize ratio from 640 to standard computer screen resolutions are simpler and therefore more pleasing when viewing full screen. Also, if you stretched 640x480 --> 704x480, you could re-encode that back to 4:3 DVD.

The reason I didn't mention this before is that you seemed to want to maximize the sharpness and detail of the image, discounting filesize entirely. I was thinking that you may want to burn it to a DVD-ROM, making the filesize restriction 4.7 gig instead of 700 meg. The more details you give us concerning what you are actually doing, the more we can help you.

I realize you may not want what you are doing scrutinized too much, but you should realize that this forum works best when you mix theory with practical application. If you stay only on theory, the thread becomes boring for us. In general, you should not focus on what you need to know, you should focus on what you are doing and let the experts tell what you need to know. (Well, it works both ways; either the answer will be along the lines that you expect or might get a surprise. You want to stay open minded.) So we need to know the application in order to even understand the question. Worst case senario, we dance around the question getting cross with each other or no one answers the question because no one is sure whether they have the answer that might really help. Being specific is almost a requirement on this forum. You started well, but we got derailed into theory alone; I brought it back to the application.

Stephen

525/60
24th February 2007, 17:56
I'm still shooting for around 710MB muxedThat's the thing Chip, I don't remember you mentioning you wanted to encode to that filesize.

Looking back now I see that when r0lZ said: IMO, 720x306 is still a bit too large for a good compression. you seemed to agree.

But then a couple of posts later, you gave this example: crop( 0, 60, -0, -62)
BilinearResize(840,358)
Completely throwing me off track. I saw immediately that was the wrong AR and tried to help with that, but I missed entirely that you were not going for that size.

IMO, I don't reccomend going below 640 and suggest that it would not be a waste of your time to actually use the following script in an encode and get back to me whether it is not a slight improvement.
Crop(8,64,-8,64)
LanczosResize(640,264)
Crop(0,4,0,-4)
Stephen

chipzoller
24th February 2007, 19:31
I meant "How do you play them on your computer?"
I'll usually play them back with MPC+ffdshow or VLC

if you try to compress a really big image too much, it acctually looks worse than a smaller image that is well encoded.
Yes, this is why I'm downsizing, but there isn't too much quality difference between 624 and 640. I prefer a somewhat smaller frame size for better compression rather than a larger size since I'm trying to fit about 2hours on a typical 1CD encode.

But then a couple of posts later, you gave this example:

crop( 0, 60, -0, -62)
BilinearResize(840,358)

That was merely an example of a proper resize and not a practical resolution which I use.

As for my exact processes, I'm only doing the following:
Compressing selected DVD movies shooting for 710MB (muxed with above audio) encoded to x264 only for home theater viewing and storing. I normally encode a frame size of anywhere from 624 up to about 640, or somewhere thereabouts. These encodes are not produced with an eventual DVD storage in mind, only for PC playback.

I try your last example and see how it works.

525/60
24th February 2007, 20:39
I try your last example and see how it works.Thanks.

I'll usually play them back with MPC+ffdshow or VLCThose are my favorites. QuickVCD is my current favorite for mpeg1/mp2 files. A narrow niche, but it does a fantastic job within that niche. Making a VCD only makes sense if you want to radically reprocess the audio or video some way, but if you do, it is a great way to save a two hour movie on one CD. Since you are saving it back to mpeg1, the aspect ratio does not have to be changed. The following script will work as long as you check the proper aspect ratio in the encoder.

Crop(8,0,-8.0)
ReduceBy2

Stephen

chipzoller
24th February 2007, 22:08
Ah, I understand fully what you mean by your suggestion of
Crop(8,64,-8,64)
LanczosResize(640,264)
Crop(0,4,0,-4)
...and I think I like this better as it gives a dead-on DAR (by the first crop and resize) and then retains mod 16 by the last crop. I was trying to do it in just one crop and resize, which was very close to the correct DAR but because I was also shooting for mod 16 it wasn't as good as I could be. I'm running a test now with
crop( 0, 56, 0, -56)
BilinearResize(640,264)
crop(0,4,-0,-4)
and will report back how it looks.

One of your first statements by getting absolute accurate results by crop-resize-crop now makes perfect sense :)

525/60
25th February 2007, 16:20
One of your first statements by getting absolute accurate results by crop-resize-crop now makes perfect sense That makes me smile. Yes, I'm sticking around until all my points make perfect sense. Partly it's the math; it's factors.

Another crop-resize-crop could be:

crop(8,48,-8,-48)
Spline16Resize(640,288)
crop(0,8,-0,-8)

This leaves a little bit of the orginal black matting though. Whereas the other one is the same as if we cropped 8 more pixels from the top and bottom. An analogy with our earlier discussion of television will explain my position and tie everything up nicely. Earlier we suggested that there is something called 'overscan'. While a little overscan is necessary for an analog interlaced TV, that is not the only reason television manufacturers make TVs that crop off the sides of the picture. The other reason is that cropping off the sides makes the image that is left bigger for a given screen dimension. Well that's perfectly analogous to the constraint that we want to have the highest possible resolution of the image while keeping the filesize as small as possible. So cropping off the sides of the picture is just another way to compress the file. It works well for TV (you never even noticed it before) so it should work well for us. This is more true than you know, because the same compromise is actually make in movie theaters. The mind reels. So what I am saying is the script you are trying now really is better than the script above.

Both scripts share the property that they are equivalent to converting a 16:9 DVD to a 4:3 DVD and then converting that to the 1:1 aspect ratio of the computer screen. When viewing a 16:9 DVD on an standard TV, the DVD player reduces the height of the frame by 25%. This is the same as multiplying the height be a ratio of 0.75. Once you have done that, the image is in the same aspect ratio as a 4:3 DVD. So, resizing in two separate steps gives:

352 x 0.75 = 264
704 x 10:11 = 640, also

384 x 0.75 = 288

This yields a general way to resize all DVDs, since if it is not an anamorphic DVD just skip the first step. The width must be divisible by 22 and the height by 8.

Stephen

chipzoller
26th February 2007, 05:30
I've done some tests encoded to 640:x and they do look quite good. I didn't encode the same film twice at two different dimensions so I can't make specific observations, but 640 is still very good. I don't think I would want to go over 640, however since some of these encodes approach 2hrs 20min and that's a lot for a 710MB (muxed) filesize.

Your previous discussion about overscan and cropping off 8px on either side...I know much of this hearkens back to what happens when DVD is played on TV, but if I can avoid cropping 'active' pixels-even if it's only 8 per side-then I'd rather do that. Of course, if there are any hints of mattes on the left and right sides, I'll crop 8 to keep mod16.
One thing I have noticed just calculating proper frame size for our crop-resize-crop method is to leave enough matting (which is almost always the case in mine) so that the PAR is achieved exactly when resized to 640:x...after the PAR is establish the remainder can be cropped (to mod16), but since the amount of matting varies for each film this method obviously has to be tailored for each encode. This is fine. I'll just need to do more practicing so I get the processes and numbers right in my mind.

525/60
28th February 2007, 16:45
OOPS, I made a mistake. 704:352 = 720:360 = 2.

If this works: Crop(8,64,-8,-64)
LanczosResize(640,264)
Crop(0,4,0,-4)
then this does too: Crop(0,60,-0,-60)
LanczosResize(640,264)
Crop(0,4,0,-4)
I think the first one crops too much from the top and bottom. Fitting a 2.39 DAR movie into a 2.5 DAR means cropping a little of the picture so that the frame is 16 mod. Cropping off more than you would need to make it 16 mod is unaccaptable.

@chipzoller
Besides, this doubles for my example of using the entire width rather than cropping off the sides. It really makes more sense to use the entire line if your target DAR is wider than it should be. Somehow I got turned around in the discussion.

@all
I believe it is the prevailing wisdom that 1.85 is the best aspect ration for films. I really can't back up that statement. The eye is not meant to see the entire CinemaScope image as once. In the theater the sides should wrap around the audience beyond the seating on either side. Most of the action takes place in the middle. If any action takes place on the side, the viewer must turn his head to see it. It there is action on both sides at the same time, the eyes must ping pong between them. This is an almost gimmiky effect. The sides of 1.85 image are close enough to be viewed simuteaneously. Nowadays the screen never wraps around the audience beyond the seating, so the sides of a CinemaScope movie must be cropped dramatically down to at least 2.2 or 2.0 and sometimes to 1.85 in a small theater. People making CinemaScope movies know that this is going to happen and plan the shots accordingly. CinemaScope was meant to go beyond your field of vision to give you an immersive experience similiar to IMAX today.

@chipzoller
but since the amount of matting varies for each film this method obviously has to be tailored for each encode. Well, there are a limited amount of templates you could use; there is just a lot of them. Every 2.39 movie on a 16:9 DVD could use the same script for instance. A 2.39 movie encoded on a 4:3 DVD would need a different script. Movies are commonly 1.375 1.66 1.75 1.85 2.2 2.39. 16:9 DVDs are made only for movies with aspect ratios greater than 1.78 except for moves that are cropped to fit 1.78, but any movie can be encoded to a regular 4:3 DVD. 1.375 aspect ratio movies are never cropped to fit a 16:9 DVD, yet they are almost always cropped to fit a 4:3 DVD, since otherwise there would be a hint of black matting on the top and bottom.

Stephen