()
| 60 | } |
| 61 | |
| 62 | export 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 | |
| 84 | let cachedGpuEncoder: GpuEncoder | undefined = undefined; |
| 85 |
no test coverage detected