Bunny Stream
Overzicht
Section titled “Overzicht”Video’s worden niet opgeslagen in R2 maar gehost bij Bunny Stream. Dit scheidt video processing van de Beam infrastructure en telt niet mee in de site storage quota (500 MB).
Upload Flow (TUS Protocol)
Section titled “Upload Flow (TUS Protocol)”Gebruiker selecteert video → POST /media/video/upload (Beam API) → API genereert SHA256 presigned headers via crypto.subtle → Media record aangemaakt (bunny_status: 0) → Response: { mediaId, presignHeaders, uploadUrl } → Client uploadt direct naar Bunny CDN (TUS resumable upload) → Bunny encodeert video → useVideoEncodingPoll() pollt batch endpoint → bunny_status: 4 = klaar voor afspelenPresigned Upload
Section titled “Presigned Upload”De API Worker genereert SHA256 presigned headers met crypto.subtle (Web Crypto API, beschikbaar in Workers runtime). De client uploadt vervolgens direct naar Bunny CDN — het videobestand gaat niet via de Beam API. Dit voorkomt payload-limieten en Worker CPU-tijd.
Database Schema
Section titled “Database Schema”Video metadata wordt opgeslagen in de media tabel:
| Kolom | Type | Beschrijving |
|---|---|---|
bunny_video_id | text | Bunny video identifier |
bunny_library_id | text | Bunny library identifier |
bunny_status | integer (0-5) | Encoding status |
duration | float | Video duur in seconden |
Status Codes
Section titled “Status Codes”| Status | Betekenis |
|---|---|
| 0 | Created (wacht op upload) |
| 1 | Uploading |
| 2 | Processing |
| 3 | Transcoding |
| 4 | Finished (klaar voor afspelen) |
| 5 | Error |
Beperkingen
Section titled “Beperkingen”| Limiet | Waarde |
|---|---|
| Max bestandsgrootte | 100 MB |
| Ondersteunde formaten | MP4, WebM, MOV |
| Niet meegeteld in | Site storage quota (500 MB) |
Encoding Status Polling
Section titled “Encoding Status Polling”Status updates via useVideoEncodingPoll() hook in het dashboard (zie Technische Stack — State Management):
- Batch API — pollt meerdere video’s tegelijk via
PATCH /media/video/:id/status - Exponential backoff — start bij 2s, verdubbelt tot max 30s
- Ref pattern —
useRefvoor stabiele callback references (geen stale closures) - Optimistic SWR update — bij status 4 (Finished) wordt de SWR media cache direct bijgewerkt zonder revalidatie
Webhook-integratie voor push-based status updates is gepland maar nog niet geïmplementeerd.