ClipForge

A video-hosting backend on Laravel 12. Uploads go through a Redis queue, FFmpeg cuts tube-style hover previews, ImageMagick makes thumbnails, and the catalog is served from a Redis cache.

PHP 8.3Laravel 12MySQL 8Redis 7FFmpegImageMagickjQueryDockernginxPHPUnitGitHub Actions

Demo: real pipeline output

These thumbnails and previews came out of ClipForge's own processing job. Hover a card (or tap it on mobile) to play the preview.

GitHub Pages only serves static files, so this page shows processed results. The full app (uploads, queue, API) runs with one docker compose up.

What happens on upload

The HTTP request only validates and stores the file. Everything heavy happens in a queue worker.

UploadAJAX with a progress bar. Mime and size are validated, and the original goes to private storage
QueueA ProcessVideo job lands on the Redis media queue. It is unique per video, with 2 tries
ffprobeReads duration and resolution, and rejects files with no video stream
ThumbnailFFmpeg grabs a frame at 30%. ImageMagick center-crops it to a 640×360 WebP
PreviewThree 2-second segments, concatenated, no audio, with +faststart
ReadyThe catalog cache version is bumped, and a Telegram notification is sent (best effort)

Engineering decisions

The parts a video platform needs to hold up under load.

ProblemSolution
Encoding blocks requestsProcessing runs in a queue worker. retry_after (700 s) is set above the job timeout (600 s), so a long encode is never picked up twice.
Hottest read: the catalogPages are cached in Redis and invalidated with a version counter: a single INCR retires every cached page, and no cache tags are needed.
View counter = hot-row UPDATEWrite-behind: each view is a Redis HINCRBY. A scheduled command drains the hash with an atomic RENAME and applies the counts in one transaction every minute.
Heavy grid pagesSmall WebP thumbnails. The preview <video> element is created only on first hover.
Third-party API is downThe Telegram notifier uses a timeout and retries, and logs errors without failing the job.
Shell injection via filenamesAll binaries run through argument arrays, never string concatenation.

Run it locally

git clone https://github.com/trump-sudo/clipforge.git
cd clipforge
docker compose up -d --build
# open http://localhost:8080

docker compose exec app php artisan test   # 15 tests