View Full Version : vspreview: Correct the DVD Aspect Ratio
jay123210599
17th May 2026, 00:31
I'm trying to correct the aspect ratio of a DVD video. I tried using this to get 704x528, but I only get 720x528. https://imgbox.com/4Pums6qa
sar = Sar.from_ar(704, 480, Dar(4, 3))
if sar > 1:
width, height = mod2(clip.width * float(sar)), mod4(clip.height)
else:
width, height = mod2(clip.width), mod4(clip.height / float(sar))
How do I fix this to get the correct aspect ratio?
Video who's aspect ratio I want to fix: https://www.mediafire.com/file/u6zmbxoyun9d7lr/VTS_01_2_%25282%2529_edit.mkv/file
Examples of the what the video should be with the aspect ratio corrected: https://www.mediafire.com/file/deowdo4ljstoty3/DVD_Example_1.mkv/file https://www.mediafire.com/file/eabyfpxvur16060/DVD_Example_2.mkv/file
hello_hello
17th May 2026, 06:01
It makes sense because sar=0.909090909091, therefore based on the else statement you'd get
width, height = 720, 408x0.909090909091
assuming the width of the DVD is 720.
I'm not a regular VapourSynth user so I'm not sure where some of the functions you're using come from, but you could try CropResize (https://forum.doom9.org/showthread.php?t=176667).
FFMS2 adds an 8:9 SAR to frame properties, so this would give you a width of 704 rather than the SAR you're calculating, which is 10:11. I think 10:11 is more likely to be correct though.
import CropResize as cr
clip = core.ffms2.Source('VTS_01_2 (2)_edit.mkv', fpsnum=25, fpsden=1)
clip = cr.CropResize(clip, 0,528)
By the way, these two lines should give you the same SAR of 10:11, if I understand the function correctly.
sar = Sar.from_ar(704, 480, Dar(4, 3))
sar = Sar.from_ar(720, 480, Dar(15, 11))
Whereas this will result in the resizing you're expecting (I think) with a SAR of 8:9
sar = Sar.from_ar(720, 480, Dar(4, 3))
You could try this with CropResize. If you specify only a width or only a height and zero for the other one, it'll calculate the other automatically for you. For your example the output would still be 720x528 though...
sar = Sar.from_ar(704, 480, Dar(4, 3))
if sar > 1:
clip = cr.CropResize(clip, mod2(clip.width*float(sar)),0, InSAR=float(sar))
else:
clip = cr.CropResize(clip, 0,mod4(clip.height/float(sar), InSAR=float(sar))
To get an output of 704x528, you either need to use a SAR of 8:9, so you'd effectively be doing:
clip = cr.CropResize(clip, 0,528, InSAR=8/9, Info=True) or
clip = cr.CropResize(clip, 0,528, InDAR=4/3, Info=True)
https://imgur.com/mO24VcT
Or based on a SAR of 10:11, you need to crop 8 pixels from each side for 704x528:
clip = cr.CropResize(clip, 0,528, 8,8,0,0, InSAR=10/11, Info=True) or
clip = cr.CropResize(clip, 0,528, 8,8,0,0, InDAR=15/11, Info=True)
https://imgur.com/EXJwDhW
As your sample doesn't actually need to have 8 pixels cropped from each side though, you could crop less and resize to 712x528.
clip = cr.CropResize(clip, 0,528, 4,4,0,0, InSAR=10/11, Info=True)
https://imgur.com/bdDX8ZI
PS It's fairly easy to calculate the SAR if you know the dimensions and the display aspect ratio you want to use for the source.
sar = 480 * 4 / 3 / 720 = 0.888888888889 (8:9)
sar = 480 * 15 / 11 / 720 = 0.909090909091 (10:11)
.
jay123210599
17th May 2026, 15:48
I got this error. How do I fix it?
clip = cr.CropResize(clip, 0,mod4(clip.height/sar), InSAR=sar)
File "C:\Users\User\Downloads\CropResize.py", line 72, in CropResize
raise vs.Error(f'{CRE}{k} must be {VType}')
vapoursynth.Error:
CropResize:
InSAR must be an integer or float
jay123210599
17th May 2026, 18:59
Also, here's my full original command (sorry I forgot one part):
dar = Dar(4, 3)
sar = Sar.from_ar(704, 480, dar)
if sar > 1:
width, height = mod2(clip.width * float(sar)), mod4(clip.height)
else:
width, height = mod2(clip.width), mod4(clip.height / float(sar))
clip_resized = Bicubic().scale(clip, width, height, keep_ar=True, sar=sar)
hello_hello
18th May 2026, 03:13
I got this error. How do I fix it?
clip = cr.CropResize(clip, 0,mod4(clip.height/sar), InSAR=sar)
File "C:\Users\User\Downloads\CropResize.py", line 72, in CropResize
raise vs.Error(f'{CRE}{k} must be {VType}')
vapoursynth.Error:
CropResize:
InSAR must be an integer or float
Ah... now I understand why you were converting the sar to float. The from_ar function must return a string and I assumed it'd be a float value. This should do it.
clip = cr.CropResize(clip, 0,mod4(clip.height/float(sar)), InSAR=float(sar))
jay123210599
18th May 2026, 15:21
I tried your solution but the height is wrong. It's supposed to be 528, or 580. How do I fix that?
https://imgbox.com/z2x6RCT1
hello_hello
19th May 2026, 04:28
I haven't seen the script you've used and I still don't know where the functions you're using came from, but simulating what I assume the mod4 function is doing...
Without cropping, I get 720x540 when using a SAR of 8:9 and 720x528 when using a SAR of 10:11, both of which are correct for the SARs.
sar = 480 * (4 / 3) / 720 # (0.888888888889 or 8:9)
# Resize & round height to mod4.
H = round(clip.height / sar / 4) * 4 # 540
clip = cr.CropResize(clip, 0,H, InSAR=float(sar), Info=True)
clip.set_output()
https://imgur.com/U6ftA8b
sar = 480 * (15 / 11) / 720 # (0.909090909091 or 10:11)
# Resize & round height to mod4.
H = round(clip.height / sar / 4) * 4 # 528
clip = cr.CropResize(clip, 0,H, InSAR=float(sar), Info=True)
clip.set_output()
https://imgur.com/8A1XzdD
When you specify a width and/or height for CropResize it resizes to the specified width and/or height, so if it's outputting a height of 580 as a result of the mod4 function, it must be due to the mod4 function outputting 580 for some reason.
704x580 in your screenshot doesn't make sense if you're resizing for a 1:1 SAR, as 704/580 = 1.2138. Did you apply a lot of cropping?
You can just keep the original width, if that's the aim, and let CropResize calculate the new height for you. By default, it resizes to mod4 when it's calculating the width and/or height itself. Here the result would once again be 720x528.
sar = 480 * (15 / 11) / 720 # (0.909090909091 or 10:11)
clip = cr.CropResize(clip, 720,0, InSAR=float(sar), Info=True)
clip.set_output()
Or more succinctly
clip = cr.CropResize(clip, 720,0, InSAR=10/11, Info=True)
clip.set_output()
So going back to your original function based on a sar of 10:11 for a 4:3 DVD, and 32:27 for a 16:9 DVD, I think this is the result you're looking for (for a 16:9 DVD the width is resized and for a 4:3 DVD the height is resized):
sar = float(Sar.from_ar(720, 480, Dar(15, 11))) # should be 0.909090909091 or 10:11
# sar = float(Sar.from_ar(720, 480, Dar(16, 9))) # should be 1.18518518519 or 32:27
if sar > 1:
clip = cr.CropResize(clip, 0,480, InSAR=sar, Info=True) # output 852x480
else:
clip = cr.CropResize(clip, 720,0, InSAR=sar, Info=True) # output 720x528
You could account for any cropping this way so you keep the cropped width and/or height instead of the original width and/or height if you prefer (changing the cropping values to zero or whatever is appropriate).
sar = float(Sar.from_ar(720, 480, Dar(15, 11))) # should be 0.909090909091 or 10:11
# sar = float(Sar.from_ar(720, 480, Dar(16, 9))) # should be 1.18518518519 or 32:27
CL = 2
CR = 2
CT = 2
CB = 2
W = clip.width - CL - CR
H = clip.height - CT - CB
if sar > 1:
clip = cr.CropResize(clip, 0,H, CL,CR,CT,CB, InSAR=sar, Info=True) # output 848x476
else:
clip = cr.CropResize(clip, W,0, CL,CR,CT,CB, InSAR=sar, Info=True) # output 716x524
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.