Created detailed documentation for regenerating GIF preview images in production environment. Guide includes: - Problem description and symptoms (404 errors for GIF files) - Three different regeneration methods: 1. Web UI tool (easiest, no terminal needed) 2. Docker environment variable (automatic on startup) 3. Direct API endpoint (for advanced users) - Step-by-step instructions for each method - Expected results and what gets created - Troubleshooting section for common issues - Technical details about GIF generation - Maintenance procedures This guide helps admins quickly resolve the production deployment issue where GIF files don't match video UUIDs. Target audience: System administrators and developers deploying to production. Co-Authored-By: Auggie
4.5 KiB
🎨 GIF Preview Regeneration Guide
Overview
This guide explains how to regenerate GIF preview images for all videos in the Znakovni.hr database. This is necessary after deploying to production because video files have different UUIDs than in development.
Problem
When you see 404 errors for GIF files like:
https://znakovni.matijaturk.from.hr/uploads/gifs/7-adresa-c9ce5c69-1768753308093.gif
Failed to load resource: the server responded with a status of 404
This means the GIF files don't exist on the production server because they were generated locally with different video UUIDs.
Solutions
Option 1: Web UI (Recommended) 🌐
Easiest method - no terminal access needed!
-
Deploy the latest Docker image:
docker pull git.matijaturk.from.hr/johnny2211/znakovni.hr:latest docker-compose down docker-compose up -d -
Open the regeneration tool in your browser:
https://znakovni.matijaturk.from.hr/regenerate-gifs.html -
Login as admin (if not already logged in)
-
Click the "🔄 Start GIF Regeneration" button
-
Wait for completion (may take several minutes depending on number of videos)
-
View results - The page will show:
- Total videos processed
- Number of successful GIF generations
- Number of failures (if any)
- Error messages for failed videos
-
Refresh the dictionary page to see the new GIF previews!
Option 2: Docker Environment Variable 🐳
Automatic regeneration on container startup:
-
Add to your docker-compose.yml or .env file:
environment: - REGENERATE_GIFS=true -
Restart the container:
docker-compose down docker-compose up -d -
Check logs to monitor progress:
docker-compose logs -f -
Remove the environment variable after first run to avoid regenerating on every restart
Option 3: API Endpoint 🔧
Direct API call (requires authentication):
curl -X POST https://znakovni.matijaturk.from.hr/api/terms/regenerate-all-gifs \
-H "Cookie: your-session-cookie" \
-H "Content-Type: application/json"
Response:
{
"total": 6,
"success": 6,
"failed": 0,
"errors": []
}
What Gets Created
For each video in the database, the system will:
- ✅ Extract frames from the video file
- ✅ Generate a GIF preview with these settings:
- Width: 300px (height auto-scaled)
- FPS: 10 frames per second
- Duration: 3 seconds
- Quality: High (palette-based encoding)
- ✅ Save GIF to
/uploads/gifs/directory - ✅ Create database record with
kind: 'GIF' - ✅ Delete old GIF files if they exist
Expected Results
On Dictionary Page:
- ✅ Words with videos → Animated GIF preview
- ✅ Words without videos → 📝 Emoji icon
- ✅ Words with videos but no GIF → "Nema pregleda" icon
In Admin Panel:
- ✅ Video and GIF displayed side-by-side
- ✅ "Regenerate GIF" button (🔄) for individual regeneration
- ✅ Green checkmark "✓ GIF preview dostupan"
Troubleshooting
GIFs still not showing after regeneration
- Check browser console (F12) for 404 errors
- Verify GIF files exist on server:
ls -lh /path/to/uploads/gifs/ - Check database records:
docker exec -it znakovni-app sh cd packages/backend npx tsx scripts/check-gifs.ts
Regeneration fails for some videos
- Check that video files exist in
/uploads/videos/ - Verify ffmpeg is installed in the container
- Check container logs for specific error messages
- Ensure sufficient disk space for GIF files
Permission errors
- Ensure
/uploads/gifs/directory is writable - Check file ownership and permissions
Technical Details
- GIF Generator: Uses ffmpeg with two-pass palette optimization
- File naming: GIFs use same filename as video but with
.gifextension - Database: GIF records stored in
term_mediatable withkind='GIF' - Cleanup: Old GIF files and database records are deleted before regeneration
Maintenance
Regenerate single GIF (Admin UI)
- Go to Admin → Terms
- Click video icon (🎥) for the term
- Click "Regenerate GIF" button (🔄)
- Wait for completion
Regenerate all GIFs (after bulk video upload)
Use Option 1 (Web UI) or Option 2 (Docker env var) from above.
Last updated: 2026-01-18
Docker image: git.matijaturk.from.hr/johnny2211/znakovni.hr:latest
Digest: sha256:5deeaa941152012c5c49823de607b365656ca21cdccb2d914a66e00497d45c9f