MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / detectGpuEncoder

Function detectGpuEncoder

packages/engine/src/utils/gpuEncoder.ts:62–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62export async function detectGpuEncoder(): Promise<GpuEncoder> {
63 return new Promise((resolve) => {
64 const ffmpeg = spawn(getFfmpegBinary(), ["-encoders"], {
65 stdio: ["pipe", "pipe", "pipe"],
66 });
67 let stdout = "";
68
69 ffmpeg.stdout.on("data", (data) => {
70 stdout += data.toString();
71 });
72
73 ffmpeg.on("close", () => {
74 const candidates = getCompiledGpuEncoders(stdout);
75 void selectUsableGpuEncoder(candidates, canUseGpuEncoder)
76 .then(resolve)
77 .catch(() => resolve(null));
78 });
79
80 ffmpeg.on("error", () => resolve(null));
81 });
82}
83
84let cachedGpuEncoder: GpuEncoder | undefined = undefined;
85

Callers 1

getCachedGpuEncoderFunction · 0.85

Calls 6

getFfmpegBinaryFunction · 0.85
getCompiledGpuEncodersFunction · 0.85
selectUsableGpuEncoderFunction · 0.85
resolveFunction · 0.85
spawnFunction · 0.70
onMethod · 0.65

Tested by

no test coverage detected