File size: 1,161 Bytes
ac7030c
1f1caeb
 
 
 
 
 
 
 
 
 
 
 
 
 
ac7030c
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 { VideoOrientation, MediaProjection } from "@/types/general"

import { parseVideoOrientation } from "./parseVideoOrientation"
import { parseProjectionFromLoRA } from "./parseProjectionFromLoRA"

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

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

  let width = 1024
  let height = 576

  if (orientation === "portrait") {
    height = 1024
    width = 576
  } else if (orientation === "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,
    projection,
    width,
    height,
  }
}