Large-video Rendering Pattern
Workers have strict memory/runtime limits, so run heavy render/extract work in E2B and stream outputs to R2.
Render Flow
- Fetch script + assets metadata from D1.
- Send render input to E2B sandbox (Remotion or Python path).
- Upload output to R2 using multipart/chunked transfer.
- Persist
rendered_videoasset row. - Post-process highlight clips and persist shorts rows.
Memory-safe Rules
- Avoid whole-file base64 for large outputs.
- Prefer 15MB multipart chunks for R2 uploads.
- For split image files, read in binary mode (
format: 'bytes') to avoid corruption.
Highlight Post-processing
- Build slide timeline from measured audio durations.
- Resolve highlight windows from slide indexes.
- Extract portrait clips in E2B.
- Seed
youtube_shorts_inforows aspendingorerror.
Failure Isolation
Render can still complete even if highlight extraction fails. Record short-level failures instead of failing the entire render stage.