How denk0403/videocrop works
Project type and purpose
• This is a single-page, browser-based, offline PWA (Progressive Web App) for video cropping.
• It uses ffmpeg.wasm to perform all video manipulation on the client, never uploading data to a server.
• Assets are hosted statically (e.g., Vercel CDN).
File structure
• Top-level: configuration files (.gitignore, .prettierrc, vercel.json), a scripts folder, README.
• public/: contains index.html, index.js, styles.css, area-selector.mjs, service-worker files (sw.js, sw-registrar.js).
• No backend or server code—pure frontend/PWA.
README for additional insights
• Confirms offline, client-only processing using ffmpeg.wasm.
• Mentions demo and usage but no server dependencies.
Main components
a. Static Hosting / CDN
• Serves index.html, scripts, styles, service-worker files.
b. Browser (Client)
• Network layer (fetches static assets)
• Service Worker
• Application Shell (UI)
• Video Input Module
• ffmpeg.wasm Engine (WebAssembly)
• Output/Download Module
c. Local Storage / Cache (optional)
• Service Worker Cache Storage for offline assets
d. External Services (minimal)
• cdn.vercel.app (for static asset hosting)
Relationships and data flow
• On first load: Browser → CDN: GET index.html, JS, CSS, sw.js
• Service Worker registration: index.js → sw-registrar.js → install sw.js
• sw.js intercepts fetch requests to cache assets and serve them offline
• User selects a video file (File API) → Video Input Module passes file to ffmpeg.wasm
• ffmpeg.wasm processes the in-memory video buffer and returns the cropped video blob
• Output Module presents download link or triggers a save dialog
Important architectural patterns and principles
• Offline-first / PWA: service worker caching, manifest-less but works offline
• Single-page Application (SPA) with module organization:
• area-selector.mjs for UI cropping rectangle
• index.js for orchestration, event handling, ffmpeg.wasm initialization
• WebAssembly integration: heavy processing offloaded to ffmpeg.wasm
• Static hosting: minimal server concerns, easier scaling and deployment