Log in

View Full Version : How to calculate resize dimensions


sugargenius
23rd January 2021, 11:31
When ripping a dvd, I am always confused about the "correct" dimensions for resizing.
Here's what I currently do:

Open a vob in mpc
Take screenshot
Crop black bars
Calculate AR
Compare to IMDB


95% of the time my calculated AR and IMDB match. That's what I input into Megui for DAR. However, I never can make sense of the resize dimensions that Megui's avisynth editor comes up with. I'll use The Mask as an example. The source is non-anamorphic, 480p dvd. After ripping, I load the dvi into Megui and change the DAR from itu 16:9 (1.823169) to 1.85. I crop 6 from the top and 12 from the bottom. Megui comes up with a resize dimensions of 720x376 yielding an AR of 1.915 and AR error of -0.37378%. My question is, why not use 720x392 (AR 1.84)? That seems a lot closer to how the movie was shot. For a 1.85 non-anamorphic dvd, shouldn't I always use 720x392? The situation I could see using another resize would be if more than combined 88 pixels cropped from top/bottom (480-88=392) as that would imply "upscaling" the vertical.
Obviously the megui author knows a million times more than me regarding video, so I am sure my logic is flawed somehow. I would just like to know how and what is the "correct" way to arrive at a resize given AR and crop.

Sharc
23rd January 2021, 15:44
The source is non-anamorphic, 480p dvd.
Really? All DVD sources are anamorphic, i.e. non-square pixel.

Secondly, your very asymmetric top/bottom cropping looks a bit unusual to me for a 1.85 movie.
Did you set some 'mod' constraint in your GUI for cropping/resizing?

sugargenius
23rd January 2021, 19:45
Here's before cropping
https://ibb.co/r0S2qMw

Here's after cropping
https://ibb.co/4JDXyy2

Sharc
24th January 2021, 15:28
Where is here?

StainlessS
24th January 2021, 19:24
sugargenius,
Your before cropping and after cropping look very similar :)

Is this of any help, [From here:- https://forum.doom9.org/showthread.php?p=1576193#post1576193 ]

Avisynth Script:

# Based on MEGUI WIKI : http://mewiki.project357.com/wiki/MeGUI/Aspect_Ratio_Signalling_in_AviSynth_Scripts
#
# SAR=Sample ie pixel Aspect Ratio. FAR=Frame Aspect Ratio (width/height). DAR=Aspect Ratio for Display.

ColorBars().ConvertToYV12().Trim(0,300) # 640x480

DAR = 16.0/9.0 # Pretend (FULL FRAME) DAR = 16/9 (Choose your variety of poison)

SAR = getSAR(DAR) # Calc SAR, no change when cropping.
#Crop(20,20,-20,-20) # We dont want to change DAR here, just testing if MEGUI actually sets 16:9 Aspect ratio correctly.

NewDAR = getDAR(SAR) # Calc new DAR after crop and before Resize. DAR no change when resizing.

LanczosResize(200,300) # Test to see if MEGUI sets DAR 16:9. (FAR = tall and skinny, MEGUI should set DAR=16:9 ie short and fat)

SignalDAR(NewDAR) # Signal DAR to MeGUI : EDIT: Change Name to SignalDAR (From SetDar)
return last

Function GetDAR(clip c, float SAR) { return Float(c.width) * SAR / Float(c.height)} # Gets the DAR from the SAR

Function GetSAR(clip c, float DAR) { return DAR * Float(c.height) / Float(c.width) } # Gets the SAR from the DAR

Function SignalDAR(float DAR) { global MeGUI_darx = Round(1000 * DAR) global MeGUI_dary = 1000 } # Signals DAR for MEGUI


DAR = 16.0/9.0 # Pretend (FULL FRAME) DAR = 16/9 (Choose your variety of poison)
Above DAR is usually 16/9 or 4/3 frame, is for FULL FRAME including letterboxing.

SAR = getSAR(DAR) # Calc SAR, no change when cropping.
Above is sample(pixel) aspect ratio.


#Crop(20,20,-20,-20) # We dont want to change DAR here, just testing if MEGUI actually sets 16:9 Aspect ratio correctly.

NewDAR = getDAR(SAR) # Calc new DAR after crop and before Resize. DAR no change when resizing.

Above, after cropping, SAR is still sample/pixel aspect ratio, so is not changed.
Then get new 'Presentation' DAR as it should be after crop, and used via MeGUI.

EDIT: If Interlaced,
Can only crop top and bottom in multiples of 4 when YV12, or Multiples of 2 if other colorspace.

EDIT:
DAR = FAR * SAR ::: FAR = DAR / SAR ::: SAR = DAR / FAR

SeeMoreDigital
24th January 2021, 23:12
When ripping a dvd, I am always confused about the "correct" dimensions for resizing....
Why are you bothering to re-encode them. Why not keep the original MPEG-2 video stream?

Nowadays HDD's are cheap and offer huge capacities!

Sharc
25th January 2021, 12:55
@sugargenius:
Not having seen your source, my best guess from your description would be:
1. The source is "480p DVD" with movie content, hence it is most probably an NTSC DVD with DAR 16:9
2. All DVD video is anamorphic by the DVD standard, there is no "non-anamorphic 480p DVD"
3. As the content seems to be a movie (The Mask) it is most likely progressive video
4. According to IMDB the movie has an aspect ratio of 1.85. Assuming 1. is true, one would expect a frame size of 720x480 with top and bottom black bars of about 10 pixels each.
After cropping, the cropped frame without borders has a size of 720x(480-20) = 720x460. It is still anamorphic with a PAR (Pixel Aspect Ratio) of 32:27=1.1852 (or a value close to it, acc. DVD or mpeg2 spec.).
5. 720x460 can be horizontally resized to 854x460 or vertically to 720x388 for square pixels (PAR 1:1) => 854/460=720/388=1.85.

Above explains the basic steps (independent of any GUI) based on some assumptions(!) about your source. (MeGUI may round a bit differently due to mod constraints.)
For better advice you would have to upload a sample.

sugargenius
25th January 2021, 13:47
Where is here?
Here are the url for screenshots. I guess they got stripped out due to my post count?

https://ibb.co/MGQDZMp

https://ibb.co/Hg1GBSn

Sharc
25th January 2021, 14:29
It's exactly as I assumed. Nothing unusual. MeGUI just shows the anamorphic source, original and cropped.
Someone who knows MeGUI may chime in and explain how it is supposed to resize with which settings, tickmarks and options .....

manolito
25th January 2021, 20:18
2. All DVD video is anamorphic by the DVD standard, there is no "non-anamorphic 480p DVD"

WHAT ???? :devil:

I think you are a bit confused about the DVD standard. Of course DVDs do not use square pixels, but this has nothing to do with anamorphic vs. non-anamorphic.

MPEG2 clips can be either flagged as 4:3 (non-anamorphic) or 16:9 (anamorphic). For 16:9 content it makes sense to encode the movie to anamorphic because you do not sacrifice vertical resolution. But for 4:3 content it does not make sense at all to encode it to 16:9 anamorphic.

I suggest you take some time to google for "anamorphic vs. non-anamorphic DVDs".

SeeMoreDigital
25th January 2021, 21:11
Sharc is correct.

Any image that requires correcting in order for it to be viewed at the proper shape is by virtue...'anamorphic'.

Sharc
25th January 2021, 22:02
It's a common misconception that someone once started to call 4:3 DVDs "non-anamorphic" and 16:9 DVDs "anamorphic. All non-square pixel formats are "anamorphic", by definition.

SeeMoreDigital
25th January 2021, 23:10
Indeed :)

manolito
25th January 2021, 23:31
It's a common misconception that someone once started to call 4:3 DVDs "non-anamorphic" and 16:9 DVDs "anamorphic. All non-square pixel formats are "anamorphic", by definition.

I think that the misconception lies at your end...

https://www.pcmag.com/encyclopedia/term/anamorphic-dvd
https://en.wikipedia.org/wiki/Anamorphic_widescreen
http://thedigitalbits.com/featured/guides/the-ultimate-guide-to-anamorphic-dvd-for-everyone
http://invisionsvc.com/Services/Projectors/Anamorphic.html

The term "Anamorphic" originates from the anamorphic lenses which were used in film cameras to make it possible to film widescreen movies on traditional 4:3 film material. For DVDs this term has a special meaning, and with the exception of you guys everybody else has agreed on what an anamorphic DVD is. To say that all non-square pixel formats are anamorphic by definition is just ridiculous... :scared:

SeeMoreDigital
25th January 2021, 23:40
The term 'anamorphic' is not solely related to lenses. It's way older than that!

Anamorphosis...

Asmodian
26th January 2021, 02:11
In this context I always use 'anamorphic' as meaning 'non-square pixels'.

If it is a dichotomy between anamorphic or not anamorphic then this seems like the only useful definition, otherwise how do you describe square pixels?

hello_hello
26th January 2021, 10:42
It's the industry that decided to call 16:9 DVDs "Widescreen Anamorphic" to differentiate them from "Full Screen" 4:3 DVDs, which filled the screen when CRTs ruled the world. If the definition of anamorphic is anything with non-square pixels, then they're all anamorphic.

The dictionary definition of anamorphic.
https://www.merriam-webster.com/dictionary/anamorphic
producing, relating to, or marked by intentional distortion
(as by unequal magnification along perpendicular axes) of an image

hello_hello
26th January 2021, 11:35
When ripping a dvd, I am always confused about the "correct" dimensions for resizing.
Here's what I currently do:

Open a vob in mpc
Take screenshot
Crop black bars
Calculate AR
Compare to IMDB


Don't do any of that. There's no guarantee the picture hasn't been cropped a little and has the exact aspect ratio as the "official" one. Plus MPC=HC always resizes to exactly 16:9 or 4:3, but the DVD could use an ITU/mpeg4 DAR which is a little wider (ITU and mpeg4 are virtually the same).

I'll use The Mask as an example. The source is non-anamorphic, 480p dvd. After ripping, I load the dvi into Megui and change the DAR from itu 16:9 (1.823169) to 1.85.

Don't do that. It's the Input DAR and there can only be two choices for a 16:9 DVD. ITU or exact 16:9. For newer 16:9 DVDs choose the latter. The DVD is anamorphic.

I crop 6 from the top and 12 from the bottom. Megui comes up with a resize dimensions of 720x376 yielding an AR of 1.915 and AR error of -0.37378%. My question is, why not use 720x392 (AR 1.84)? That seems a lot closer to how the movie was shot. For a 1.85 non-anamorphic dvd, shouldn't I always use 720x392? The situation I could see using another resize would be if more than combined 88 pixels cropped from top/bottom (480-88=392) as that would imply "upscaling" the vertical.

I had to crop a couple of extra pixels from the top to minimise aspect error, but it's very close to 1.85. Set the mod option to mod4 rather than mod8 for more accurate resizing.

https://i.postimg.cc/c64WMTWb/MeGUI1.jpg (https://postimg.cc/c64WMTWb)

Resizing the width up instead of reducing the height for maximum detail. It's mental it's disabled by default.

https://i.postimg.cc/jCgb8Ndd/MeGUI2.jpg (https://postimg.cc/jCgb8Ndd)

https://i.postimg.cc/y3dz16nH/MeGUI3.jpg (https://postimg.cc/y3dz16nH)

480 x (16/9) = 853.33 (resized to square pixel dimensions - 853.33 x 480)
853.33 / 460 (after cropping) = 1.85507
There's a very small aspect error when resizing.
852 / 460 = 1.85217
720 / 388 = 1.85567

You can also play with this function (https://forum.doom9.org/showthread.php?t=176667). I often crop with MeGUI, then remove MeGUI's cropping from the script and use the same cropping for CropResize. If you specify the correct input DAR for CropResize there can never be any aspect error, as it crops to prevent it if necessary.

MeGUI's ITU Input DAR's are possibly a little off. It uses the second lot of ITU (almost exact) pixel aspect ratios in the table I've linked to below as the basis for it's ITU DARs. I create two custom Input DARs of 20:11 and 15:11. They're the mpeg4 DARs. My rule of thumb is always use 15:11 for 4:3 DVDs, 20:11 for older 16:9 DVDs, and 16:9 for newer 16:9 DVDs.

https://i.postimg.cc/56XSvcRN/MeGUI4.jpg (https://postimg.cc/56XSvcRN)

This post (https://forum.doom9.org/showthread.php?p=1058927#post1058927) provides tables of the possible sample/pixel aspect ratios. For the mpeg4 sample/pixel aspect ratios, they work out to a display aspect ratio of 20:11 for both NTSC and PAL 16:9 DVDs, and 15:11 for 4:3 DVDs.
The generic pixel/sample aspect ratios give you exactly 16:9 and 4:3.

manolito
26th January 2021, 20:02
It's the industry that decided to call 16:9 DVDs "Widescreen Anamorphic" to differentiate them from "Full Screen" 4:3 DVDs, which filled the screen when CRTs ruled the world. If the definition of anamorphic is anything with non-square pixels, then they're all anamorphic.

Exactly, and this definition is what I grew up with. To me in the context of DVDs Anamorphic means "Widescreen Anamorphic". And this is clearly what the OP referred to when he said:
The source is non-anamorphic, 480p dvd

manono
26th January 2021, 20:14
Exactly, and this definition is what I grew up with. To me in the context of DVDs Anamorphic means "Widescreen Anamorphic". And this is clearly what the OP referred to when he said:
The source is non-anamorphic, 480p dvd
I'm not sure why you're so adamant about this. We all understood what he meant, even if he wrote it incorrectly. Then he was corrected. Maybe what he should have written was:
The source is a 4:3, 480p dvd
Except, looking at the picture it seems to be 16:9, so what he wrote about it as being non-anamorphic now seems nonsensical.

manolito
26th January 2021, 21:50
I'm not sure why you're so adamant about this.

Because I do not like when someone tries to destroy my belief system... :devil:

From an old manono post at VideoHelp:
As you well know, although anamorphic originally referred to anamorphic lenses and film, it means something quite different in the DVD world. For all intents and purposes, a movie on DVD encoded as 16:9 is an anamorphic DVD.

From the same thread by AlanHK:
Others have explained the original meaning of anamorphic, the kind of lenses used when shooting it.

For DVDs it usually means a widescreen (16:9 and others) aspect ratio distorted to fill a 4:3 frame. The 16:9 flag in the file tells the player to add letterboxing as appropriate, depending on the kind of TV you have. So a 4:3 movie is encoded full-frame, and marked 4:3, naturally.

I will stick to my definition of an anamorphic DVD. I do not subscribe to the definition that all DVDs are anamorpic by design or standards.

Sharc
27th January 2021, 09:03
..... To say that all non-square pixel formats are anamorphic by definition is just ridiculous...
No, it's not 'ridiculous'. Not at all. And I kindly ask you to stay away from offending wording in defending your position, please.

hello_hello
27th January 2021, 11:32
sugargenius may have assumed the DVD was non-anamorphic because he wasn't seeing the result of the resizing. Once you've configured the cropping and resizing, it's necessary to click on the "Preview AVS Script" button in the script creator to apply the cropping and resizing, and therefore to see the picture change shape.
Either that or you can check "Apply Auto Preview", but it slows things down as the preview is refreshed with every change.

sugargenius may also be unaware of MeGUI's anamorphic encoding abilities. I'd tend to select the "Encode non-Mod16" option, which is badly named. It should be something like "encode any mod" because the width and height mod is determined by the cropping. If you want mod4 dimensions or mod8 etc, you have to adjust the cropping to the correct mod yourself, but when "Encode non-Mod16" is chosen, resizing is disabled. The aspect ratio will look wrong but the encoded video should be stretched to the correct aspect ratio on playback. The other anamorphic encoding options allow some resizing. Whichever you choose, the display aspect ratio is shown at the top of the script. Rather than use anamorphic encoding, I generally resize to square pixel dimensions myself, although mainly because one of the players here doesn't display anamorphic video correctly.

https://i.postimg.cc/LhjKgtTJ/MeGUI5.jpg (https://postimg.cc/LhjKgtTJ)

https://i.postimg.cc/1fPxG8CJ/MeGUI6.jpg (https://postimg.cc/1fPxG8CJ)

128 / 69 = 1.85507

The acceptable aspect error option only applies to anamorphic encoding. It allows MeGUI to fudge the aspect ratio a little. It's really only useful if you want to achieve an exact 4:3 or 16:9 DAR after cropping. It's a bit like normal cropping and resizing where you crop to almost 4:3 or to almost 16:9 and resize to exact 4:3 or 16:9 dimensions.

https://i.postimg.cc/1VGkxStG/MeGUI7.jpg (https://postimg.cc/1VGkxStG)

manono
28th January 2021, 02:19
I will stick to my definition of an anamorphic DVD.
Yes, in support of that old quotation, when something like Amazon says a DVD is anamorphic, they mean 16:9. When they say something like 1.85:1, they mean widescreen 4:3. Once again media companies have expropriated a term that originally meant something else to serve their own purposes - to make a 16:9 DVD sound better - which in this case it is.

But the OP claimed his DVD was non-anamprphic. That makes no sense in either the redefined term or in the original dictionary definition of the term. No DVDs are 1:1. Therefore all are anamorphic, if using the original meaning of the word.

By the way, I checked 4 online dictionaries and only one even acknowledged the DVD definition, and as the second definition:

1. Relating to, having, or producing different optical imaging effects along mutually perpendicular radii: an anamorphic lens.
2. Of or relating to a widescreen film or video that has been converted to a storage format with a lower aspect ratio by shrinking the image only along the horizontal axis in order to minimize loss of resolution: an anamorphic DVD for widescreen televisions.