Under the Hood.
How SnapMusic transforms your static assets into viral videos using robust cloud engineering.
Upload & Validate
User uploads Image (JPG/PNG) & Audio (MP3/WAV). System validates mime-types and file integrity.
Content-Type: multipart/form-data
Queue & Encode
Job pushed to queue. Worker picks it up and triggers FFmpeg conversion.
dispatch($video)
Store & Notify
MP4 stored in private storage. Frontend polls for completion status.
storage/app/videos/{id}.mp4
📹 The FFmpeg Engine
We use FFmpeg to combine the static image and audio stream. Crucially, we apply a complex filter to ensure compatibility across all players.
Scale Filter Logic
scale=trunc(iw/2)*2:trunc(ih/2)*2
Why? H.264 encoding requires even dimensions. This filter forces width and height to be divisible by 2, preventing encoding errors on odd-sized user images.
⚡ Async Queue Workers
Video processing is heavy. To keep the UI snappy, we offload the heavy lifting to background workers.
Worker Command
php artisan queue:work --tries=3 --timeout=120
How it works: The web request finishes instantly, returning a "Pending" status. The worker picks up the job, runs FFmpeg, and updates the database state to "Completed".