mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
refactor: split constants by domain and isolate timeline panel from core
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user