Turn uploaded Uint8Array into a new MP4 file before uploading to R2
Files are uploaded to my R2 through a worker, which reads the readableStream in chunks (verifying the size because we don't trust the client and their header) and outputs a Uint8Array upon success.
I could easily use cf-wasm/photon to create new images from this Array and thus sanitize those and safely put into my bucket.
Yet I could not find a way to do the same with MP4 output. Spend quite a lot of time trying to make ffmpeg and mp4box work - sadly without success.
Motivation:
I work on a web application which accepts small video files from users for posts. Other users can then read those posts and see the videos.
The video files cannot be larger than 5mb and have to be in the mp4 format.
0 Replies