diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-04-01 19:27:49 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-04-01 19:27:49 +0200 |
| commit | bd9ec023eefc4b5d26fa8b66c4338e97104f0f96 (patch) | |
| tree | 08350eaa107b27f026eebdb65df54b1ca25521fd /apps/web/src/lib/fps/utils.ts | |
| parent | f4b9f40ab1ba1cedf208bba708f4331d36bb30cc (diff) | |
| download | opencut-bd9ec023eefc4b5d26fa8b66c4338e97104f0f96.tar.gz | |
refactor: split constants by domain and isolate timeline panel from core
Diffstat (limited to 'apps/web/src/lib/fps/utils.ts')
| -rw-r--r-- | apps/web/src/lib/fps/utils.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/web/src/lib/fps/utils.ts b/apps/web/src/lib/fps/utils.ts new file mode 100644 index 00000000..8e3221a1 --- /dev/null +++ b/apps/web/src/lib/fps/utils.ts @@ -0,0 +1,39 @@ +import type { MediaAsset } from "@/lib/media/types"; + +type MediaAssetFpsInput = Pick<MediaAsset, "type" | "fps">; + +export function getHighestImportedVideoFps({ + mediaAssets, +}: { + mediaAssets: MediaAssetFpsInput[]; +}): number | null { + let highestFps: number | null = null; + + for (const asset of mediaAssets) { + const fps = asset.fps ?? Number.NaN; + if (asset.type !== "video") continue; + if (!Number.isFinite(fps) || fps <= 0) continue; + + highestFps = highestFps === null ? fps : Math.max(highestFps, fps); + } + + return highestFps; +} + +export function getRaisedProjectFpsForImportedMedia({ + currentFps, + importedAssets, +}: { + currentFps: number; + importedAssets: MediaAssetFpsInput[]; +}): number | null { + const highestImportedVideoFps = getHighestImportedVideoFps({ + mediaAssets: importedAssets, + }); + + if (highestImportedVideoFps === null || highestImportedVideoFps <= currentFps) { + return null; + } + + return highestImportedVideoFps; +} |
