( videoPath: string, destDir: string, interactive: boolean, )
| 346 | // --------------------------------------------------------------------------- |
| 347 | |
| 348 | async function handleVideoFile( |
| 349 | videoPath: string, |
| 350 | destDir: string, |
| 351 | interactive: boolean, |
| 352 | ): Promise<{ meta: VideoMeta; localVideoName: string }> { |
| 353 | const probed = probeVideo(videoPath); |
| 354 | let meta: VideoMeta = { ...DEFAULT_META }; |
| 355 | let localVideoName = basename(videoPath); |
| 356 | |
| 357 | if (probed) { |
| 358 | meta = probed; |
| 359 | if (interactive) { |
| 360 | clack.log.info( |
| 361 | `Video: ${meta.width}x${meta.height}, ${meta.durationSeconds.toFixed(1)}s, ${meta.fps}fps${meta.hasAudio ? ", has audio" : ""}`, |
| 362 | ); |
| 363 | } |
| 364 | } else { |
| 365 | const msg = `ffprobe not found — using defaults (1920x1080, 5s, 30fps). Install: ${getFFmpegInstallHint()}`; |
| 366 | if (interactive) { |
| 367 | clack.log.warn(msg); |
| 368 | } else { |
| 369 | console.log(c.warn(msg)); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | // Check codec compatibility |
| 374 | if (probed && !isWebCompatible(probed.videoCodec)) { |
| 375 | if (interactive) { |
| 376 | clack.log.warn( |
| 377 | c.warn(`Video codec "${probed.videoCodec}" is not supported by web browsers.`), |
| 378 | ); |
| 379 | } else { |
| 380 | console.log(c.warn(`Video codec "${probed.videoCodec}" is not supported by browsers.`)); |
| 381 | } |
| 382 | |
| 383 | if (hasFFmpeg()) { |
| 384 | let shouldTranscode = !interactive; // non-interactive auto-transcodes |
| 385 | |
| 386 | if (interactive) { |
| 387 | const transcode = await clack.select({ |
| 388 | message: "Transcode to H.264 MP4 for browser playback?", |
| 389 | options: [ |
| 390 | { |
| 391 | value: "yes", |
| 392 | label: "Yes, transcode", |
| 393 | hint: "converts to H.264 MP4", |
| 394 | }, |
| 395 | { |
| 396 | value: "no", |
| 397 | label: "No, keep original", |
| 398 | hint: "video won't play in browser", |
| 399 | }, |
| 400 | ], |
| 401 | }); |
| 402 | if (clack.isCancel(transcode)) { |
| 403 | clack.cancel("Setup cancelled."); |
| 404 | process.exit(0); |
| 405 | } |
no test coverage detected