Video Compression
Shrink user-uploaded video for fast, reliable web playback.
When to use it
Raw uploads from phones and cameras are often hundreds of megabytes and encoded in formats that don't stream well. The compress-video job re-encodes them to a web-friendly H.264/MP4 at a size that plays smoothly everywhere, without you running any FFmpeg infrastructure.
Basic usage
Enqueue a job with the video URL. offload.run downloads the input, compresses it, and makes the result available when it's done.
import { Offload } from '@offload-run/sdk'
const offload = new Offload({ apiKey: process.env.OFFLOAD_API_KEY })
const job = await offload.enqueue('compress-video', {
input: 'https://example.com/raw-upload.mov',
options: {
quality: 'high',
format: 'mp4',
},
})
console.log('Job ID:', job.id)Options
qualitylow, medium, or high. Trades file size against visual fidelity. Defaults to medium.
formatOutput container: mp4 (default) or webm.
maxWidthDownscale so the longest edge fits within this many pixels (e.g. 1920 for 1080p). Aspect ratio is preserved.
Getting the result
Video jobs can take a while, so the recommended pattern is to pass a webhookUrl and let offload.run notify you when the job finishes rather than polling.
await offload.enqueue('compress-video', {
input: 'https://example.com/raw-upload.mov',
options: { quality: 'high', maxWidth: 1920 },
webhookUrl: 'https://yourapp.com/api/webhooks/offload',
})See the Webhooks guide for the payload shape and how to verify signatures. To poll instead, call GET /jobs/:id until the status is completed.
Tips
- For social-style feeds,
maxWidth: 1280withquality: 'medium'is a good balance of size and clarity. - Generate a poster image in the same flow with a separate
video-thumbnailjob. - Compression is idempotent per input URL — re-enqueue safely if a webhook delivery is missed.