Skip to content

Instantly share code, notes, and snippets.

@wiwaz
Last active May 5, 2023 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wiwaz/40883bae396bef5eb9fc99d4de2377ec to your computer and use it in GitHub Desktop.
Save wiwaz/40883bae396bef5eb9fc99d4de2377ec to your computer and use it in GitHub Desktop.
# 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