Last active
May 5, 2023 15:17
-
-
Save wiwaz/40883bae396bef5eb9fc99d4de2377ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in vstools now, gist no longer useful | |
import vapoursynth as vs | |
from math import gcd | |
def get_dar(width: int, height: int) -> tuple: | |
dar = gcd(width, height) | |
return (width // dar, height // dar) | |
def get_sar(dar: tuple, height: int, active_area: int) -> tuple: | |
sar = dar[0] * height, dar[1] * active_area | |
sargcd = gcd(sar[0], sar[1]) | |
return (sar[0] // sargcd, sar[1] // sargcd) | |
def sar_to_props(clip: vs.VideoNode, sar: tuple) -> vs.VideoNode: | |
clip = clip.std.SetFrameProps(_SARDen=sar[0], _SARNum=sar[1]) | |
return clip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment