( exitCode: number | null, stderr: string, tailLines: number = DEFAULT_STDERR_TAIL_LINES, )
| 55 | * exactly which option to fix. |
| 56 | */ |
| 57 | export function formatFfmpegError( |
| 58 | exitCode: number | null, |
| 59 | stderr: string, |
| 60 | tailLines: number = DEFAULT_STDERR_TAIL_LINES, |
| 61 | ): string { |
| 62 | const tail = (stderr ?? "") |
| 63 | .split(/\r?\n/) |
| 64 | .filter((line) => line.length > 0) |
| 65 | .slice(-tailLines) |
| 66 | .join("\n"); |
| 67 | if (exitCode === null) { |
| 68 | return tail ? `[FFmpeg] ${tail}` : "[FFmpeg] process error"; |
| 69 | } |
| 70 | const windowsMessage = formatWindowsFfmpegExit(exitCode); |
| 71 | if (windowsMessage) { |
| 72 | return tail ? `${windowsMessage}\nffmpeg stderr (tail):\n${tail}` : windowsMessage; |
| 73 | } |
| 74 | return tail |
| 75 | ? `FFmpeg exited with code ${exitCode}\nffmpeg stderr (tail):\n${tail}` |
| 76 | : `FFmpeg exited with code ${exitCode}`; |
| 77 | } |
| 78 | |
| 79 | export async function runFfmpeg(args: string[], opts?: RunFfmpegOptions): Promise<RunFfmpegResult> { |
| 80 | const startMs = Date.now(); |
no test coverage detected