feat: web video transcoding, admin playback, and viewer fixes
CI / skip-ci-check (pull_request) Successful in 1m4s
CI / lint-and-type-check (pull_request) Has been cancelled
CI / python-lint (pull_request) Has been cancelled
CI / test-backend (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
CI / secret-scanning (pull_request) Has been cancelled
CI / dependency-scan (pull_request) Has been cancelled
CI / sast-scan (pull_request) Has been cancelled
CI / workflow-summary (pull_request) Has been cancelled

Add on-demand H.264/AAC web playback (RQ, ffmpeg) with API routes and
Next.js proxies; extend admin UI with WebPlaybackVideo and shared hooks.
Store transcode cache beside pending-photos (WEB_VIDEO_CACHE_DIR / UPLOAD_DIR)
and ignore data/web_videos. Centralize FastAPI URL helpers, optional Vite
and Next base paths for subfolder deploy, and fix modal reopen by using
router.replace when closing the home photo viewer. Include migration,
install scripts, deployment doc updates, and CI admin build env tweak.

Made-with: Cursor
This commit is contained in:
Tanya
2026-03-25 15:33:05 -04:00
parent c316da02a4
commit ff47c87e41
45 changed files with 1531 additions and 121 deletions
@@ -0,0 +1,34 @@
/**
* FastAPI base URL for Next.js route handlers (server-side fetch only).
*
* Set BACKEND_BASE_URL to the **mount point** of FastAPI (no trailing slash).
* This helper appends `/api/v1` and the resource path. It matches how the
* browser sees versioned routes when the proxy maps `/punim-api/` → FastAPI root:
*
* BACKEND_BASE_URL=https://jrccphotos.org/punim-api
* fastApiV1Url(`/videos/5/web-playback/stream`)
* → https://jrccphotos.org/punim-api/api/v1/videos/5/web-playback/stream
*
* On the same host as the API process you may use `http://127.0.0.1:8000` instead
* (still produces `.../api/v1/...` on port 8000). If BACKEND_BASE_URL already ends
* with `/api/v1`, it is not duplicated.
*/
function normalizeBackendBase(): string {
const raw = (process.env.BACKEND_BASE_URL || 'http://127.0.0.1:8000').trim();
return raw.replace(/\/+$/, '');
}
/**
* Full URL for a resource under FastAPI's /api/v1 prefix.
*
* @param resourcePath Path after /api/v1, e.g. `/videos/5/web-playback/stream`
*/
export function fastApiV1Url(resourcePath: string): string {
const base = normalizeBackendBase();
const path = resourcePath.startsWith('/') ? resourcePath : `/${resourcePath}`;
if (/\/api\/v1$/i.test(base)) {
return `${base}${path}`;
}
return `${base}/api/v1${path}`;
}