OpenCut/apps/web
Andrés Villagrán 7204146467 feat(media): support browsers without WebCodecs via FFmpeg + HTML5 fallbacks
OpenCut's video preview and audio playback both rely on mediabunny, which
in turn requires the WebCodecs API (VideoDecoder / AudioDecoder). On
browsers where WebCodecs is not exposed (e.g. Linux Chromium builds
without proprietary codec support), import and playback both throw
"codec not supported" errors and the editor becomes unusable.

This change makes the editor work on those browsers without sacrificing
the WebCodecs fast-path elsewhere:

- Add a server-side /api/convert-video route that transcodes incoming
  videos to H.264 baseline 3.1 yuv420p via the system ffmpeg binary.
  processMediaAssets uses it automatically when readVideoFile reports
  canDecode=false so the asset stored is always something the browser
  can play.
- Add HTMLVideoElementSink, a CanvasSink-shaped sink backed by a
  hidden <video> element + canvas.drawImage. VideoCache.initializeSink
  selects it only when WebCodecs VideoDecoder is unavailable; otherwise
  it keeps using mediabunny's CanvasSink unchanged.
- Add FallbackAudioBufferSink, an AudioBufferSink-shaped sink backed by
  AudioContext.decodeAudioData (which uses the platform's native audio
  decoders, not WebCodecs). AudioManager and the import-time decode
  path swap to it on canDecode=false. runClipIterator is wrapped in a
  try/catch so a sink failure no longer leaves an unhandled rejection.

Tests cover frame timing, dispose semantics, FPS clamping, the
WebCodecs/AudioDecoder availability probes, AudioBuffer slicing, and
the fallback iterator contract.
2026-05-16 20:23:54 -04:00
..
migrations chore: normalize line endings 2026-03-29 15:56:48 +02:00
public chore: delete ffmpeg public assets 2026-04-21 13:00:26 +02:00
scripts chore: normalize line endings 2026-03-29 15:56:48 +02:00
src feat(media): support browsers without WebCodecs via FFmpeg + HTML5 fallbacks 2026-05-16 20:23:54 -04:00
.env.example chore: remove transcription envs 2026-04-04 08:53:10 +02:00
.gitignore chore: update .gitignore 2026-03-29 18:55:56 +02:00
Dockerfile chore: remove transcription envs 2026-04-04 08:53:10 +02:00
components.json chore: normalize line endings 2026-03-29 15:56:48 +02:00
content-collections.ts feat: new-release notice and colocate changelog under domain 2026-04-15 02:05:41 +02:00
drizzle.config.ts fix: correct schema path in drizzle config 2026-04-15 06:04:29 +02:00
next.config.ts feat: migrate GPU renderer from WebGL to wgpu/WASM 2026-04-01 13:57:32 +02:00
open-next.config.ts chore: add missing open-next config 2026-03-29 15:58:46 +02:00
package.json chore: switch from biome to eslint + prettier; fix ton of lint issues 2026-05-02 03:27:23 +02:00
postcss.config.mjs feat: masks, properties refactor, shaders, storage migrations, and more 2026-03-29 15:48:22 +02:00
tsconfig.json chore: switch from biome to eslint + prettier; fix ton of lint issues 2026-05-02 03:27:23 +02:00
wrangler.jsonc chore: normalize line endings 2026-03-29 15:56:48 +02:00