(filePath: string)
| 64 | } |
| 65 | |
| 66 | export async function isPlayableVideo(filePath: string): Promise<boolean> { |
| 67 | try { |
| 68 | const validatorPath = await getVideoValidatorExecutablePath(); |
| 69 | const result = await runCmd(validatorPath, [filePath], { |
| 70 | allowFailure: true, |
| 71 | timeoutMs: 10_000, |
| 72 | env: buildSwiftToolEnv(), |
| 73 | }); |
| 74 | if (result.exitCode === 0) { |
| 75 | return true; |
| 76 | } |
| 77 | if (isSwiftVideoValidatorUnavailable(result.stderr, result.stdout)) { |
| 78 | return hasLikelyPlayableVideoContainer(filePath); |
| 79 | } |
| 80 | return false; |
| 81 | } catch (error) { |
| 82 | if (isSwiftVideoValidatorError(error)) { |
| 83 | return hasLikelyPlayableVideoContainer(filePath); |
| 84 | } |
| 85 | throw error; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | async function getVideoValidatorExecutablePath(): Promise<string> { |
| 90 | videoValidatorExecutablePathPromise ??= compileSwiftSourceText({ |
no test coverage detected