File size: 1,178 Bytes
e864e26
1f1caeb
f24ad59
52d39bb
1f1caeb
 
 
 
 
 
 
 
 
 
52d39bb
ac7030c
1f1caeb
 
 
 
 
52d39bb
1f1caeb
 
 
 
 
52d39bb
1f1caeb
 
52d39bb
1f1caeb
 
 
 
 
 
 
 
 
 
 
 
 
 
52d39bb
1f1caeb
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { MediaProjection } from "@/types/general"

import { parseProjectionFromLoRA } from "../parsers/parseProjectionFromLoRA"
import { ClapImageRatio, parseImageRatio } from "@aitube/clap"

export function computeOrientationProjectionWidthHeight({
  lora: maybeLora,
  projection: maybeProjection,
  orientation: maybeOrientation,
}: {
  lora?: any
  projection?: any
  orientation?: any
}): {
  orientation: ClapImageRatio
  projection: MediaProjection
  width: number
  height: number
} {

  const lora = `${maybeLora || ""}`
  const imageRatio = parseImageRatio(maybeOrientation)
  const projection = maybeProjection ? maybeProjection : parseProjectionFromLoRA(lora)

  let width = 1024
  let height = 576

  if (imageRatio === ClapImageRatio.PORTRAIT) {
    height = 1024
    width = 576
  } else if (imageRatio === ClapImageRatio.SQUARE) {
    height = 512
    width = 512
  } else {
    width = 1024
    height = 576
  }

  // now for equirectangular videos we need to have the correct image ratio of 2:1
  if (projection === "equirectangular") {
    width = 1024
    height = 512
  }

  return {
    orientation: imageRatio,
    projection,
    width,
    height,
  }
}