View Single Post
Old 6th May 2020, 07:41   #5  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
Time for a shameless plug.... assuming you're using Avisynth.
https://forum.doom9.org/showthread.php?t=176667

There's usage examples in the second post, but if you're wanting to resize to square pixel dimensions here's a short(ish) explanation. To stretch the width without resizing the height, you'd specify zero for both the width and height, followed by your desired cropping, followed by the DVD's display aspect ratio or sample/pixel aspect ratio, followed by the argument for disabling height resizing. The script will take care of the rest.

CropResize(0,0, 6,20,-8,-22, InDAR=16.0/9.0, ResizeWO=true)

If you're not fussed about having specific output dimensions but you want to resize to a specific width, you can specify the width and any cropping etc, and the script will take care of the height.

CropResize(1024,0, 6,20,-8,-22, InDAR=16.0/9.0)

If you want specific output dimensions you need to remember the script will crop to prevent aspect error, but if you want every encode to have the same dimensions... for example 1024x576, which is 16:9.... the script will apply any specified cropping, then any extra cropping required so the remaining picture is 16:9 (any specified cropping is the minimum cropping), then it'd resize to 1024x576.

CropResize(1024,576, 6,20,-8,-22, InDAR=16.0/9.0)

Normally if your cropping didn't result in the cropped picture having the appropriate aspect ratio, the resizer would stretch or squish it. CropResize crops instead to prevent that. Often it's only necessary to specify a width and/or use ResizeWO mode, but specifying both a width and height makes it easy to ensure a bunch of related encodes have the same dimensions, without having to calculate aspect error for each one and adjust the cropping to minimise it.

Personally, I either resize to square pixel dimensions or I don't resize at all (just crop) and keep the original pixel aspect ratio when encoding. That's generally fine for x264 but it's probably better to resize to square pixel dimensions for Xvid. Keep in mind, stretching the width before encoding will mean there's more video to encode than if you encoded anamorphically, so the resulting file size will be greater for a particular encoding quality.

As for the pixel aspect ratios.... there's an explanation in the help file under the InDAR description, and a link to the table here.
https://forum.doom9.org/showthread.p...27#post1058927
You generally only need to decide between using a generic aspect ratio or an mpeg4 aspect ratio, but instead of using the pixel/sample aspect ratios you can specify the display aspect ratio for CropResize. So for a generic pixel aspect ratio you'd specify InDAR=16.0/9.0 or InDAR=4.0/3.0. For an mpeg4 pixel aspect ratio it's InDAR=20.0/11.0 or InDAR=15.0/11.0. That applies to both PAL and NTSC.

If you resize with the script, you must specify an input DAR or SAR for DVDs, because the shape of the pixels needs to be factored into the resizing calculations. You can also specify an OutDAR or OutSAR rather than resize to "square pixel" dimensions, and the script can add borders if need be, but unless you're encoding for an industry format such as DVD, I'd just crop the black and resize.

PS. Always use InDAR=15.0/11.0 for 4:3 DVDs. If there's not much black down each side of a 16:9 DVD, InDAR=16.0/9.0 is more likely to correct, especially for newer DVDs. For older DVDs or DVDs with a substantial amount of black on the sides, InDAR=20.0/11.0 is a safer bet. The difference isn't huge anyway. Around 2%.

Cropping DVDs works the same as for cropping Bluray. If you only crop, the pixel/sample aspect ratio doesn't change because the pixels are still the same shape, but there's less picture so the display aspect ratio changes. Resizing, at least for the purpose of this discussion, changes the pixel/sample aspect ratio, but it shouldn't change the display aspect ratio. ie

A 16:9 PAL DVD is 720x576 but the player will resize it to 16:9, so it's display dimensions are 1024x576. Therefore if you resize to 1024x576 and encode, the display aspect ratio hasn't changed, but the shape of the pixels did (and there's more of them). Obviously if you resize 1920x1080 to 1280x720 the display aspect ratio remains the same, and because the widths and heights have same proportions, the PAR didn't change either.

Last edited by hello_hello; 6th May 2020 at 18:11.
hello_hello is offline   Reply With Quote