Page:
CDN: Animated and still images
No results
8
CDN: Animated and still images
yun edited this page 2026-09-23 07:44:11 +02:00
Heavyweight -> Separated service
When the user sends an image
- frontend sends image to backend
- backend publishes image (Valkey pubsub)
- CDN subscribed, recieves image
- CDN generates an UUID for this image
- CDN saves the association (
UUID,hash,completed) withcompletedset tofalse- postgres? sqlite? simple key-value db?
- key-value is simple, probably faster for associations this simple
- postgres keeps the same stack and allows for adding more data later (keywords, date, description, ...)
- postgres? sqlite? simple key-value db?
- CDN sends an access URL to the backend
- backend sends the URL to the frontends (so the message appears immediately, without the image)
- CDN converts to AVIF (supports animated and still images, good compression, but slow)
ffmpeg -i INPUT -an -c:v libsvtav1 -crf 35 -preset 6 -svtav1-params 'fast-decode=2' -g 1 -loop 0 -f avif OUTPUT- other option: WebP -> gain conversion speed, looses compression
- look up: limit at max 20 fps?
- look up: use AV1 for animated images? gain inter-frames compression, but lose ability to display as images.
- something like
ffmpeg -i INPUT -an -c:v libsvtav1 -crf 35 -preset 6 -svtav1-params 'fast-decode=2' -g 60 -f webm OUTPUT
- something like
- CDN wipes the metadata (
mat2? or manual wipe withffmpeg?) - CDN stores the resulting image with a hash as the name
- perceptual hash? only works for still images
- sha256? works for everything but allow duplicate images (if they are slightly different quality, size or encoding, different codec... the sha256 will be different)
- frontends load the image
When CDN finished processing the image
- CDN sends a message to the backend with the UUID
- backend notify frontends that the image is ready
When a frontend loads the image
- frontend sends a
GETrequest with the URL - CDN looks up the DB
- [OPTION] the image is
completed- CDN gets the image identified by
hashand returns it to the frontend
- CDN gets the image identified by
- [OPTION] the image is not
completed- CDN sends an HTTP response code 425 (Too Early)
- [OPTION] the image is not in the DB
- CDN sends an HTTP response code 404 (Not Found)
Note: add an admin-customizable file size limit