mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
perf(engine): a --gpu render probes the GPU encoders once, not twice (#6638)
* perf(engine,cli): a machine's GPU encoder probe runs once, not on every render * refactor(engine): one shared probe per process, no answer kept on disk
This commit is contained in:
@@ -80,15 +80,17 @@ export async function detectGpuEncoder(): Promise<GpuEncoder> {
|
||||
return selectUsableGpuEncoder(candidates, canUseGpuEncoder).catch(() => null);
|
||||
}
|
||||
|
||||
let cachedGpuEncoder: GpuEncoder | undefined = undefined;
|
||||
let cachedGpuEncoder: Promise<GpuEncoder> | undefined = undefined;
|
||||
|
||||
export async function getCachedGpuEncoder(): Promise<GpuEncoder> {
|
||||
if (cachedGpuEncoder === undefined) {
|
||||
cachedGpuEncoder = await detectGpuEncoder();
|
||||
}
|
||||
export function getCachedGpuEncoder(): Promise<GpuEncoder> {
|
||||
cachedGpuEncoder ??= detectGpuEncoder();
|
||||
return cachedGpuEncoder;
|
||||
}
|
||||
|
||||
export function resetCachedGpuEncoder() {
|
||||
cachedGpuEncoder = undefined;
|
||||
}
|
||||
|
||||
export function getGpuEncoderName(encoder: GpuEncoder, codec: "h264" | "h265"): string {
|
||||
if (!encoder) return codec === "h264" ? "libx264" : "libx265";
|
||||
switch (encoder) {
|
||||
|
||||
Reference in New Issue
Block a user