Skip to content

Compress Video

The compress recipe re-encodes video with H.264 at a configurable quality level (CRF). This is the most common way to reduce file size for web delivery.

Terminal window
curl -X POST https://api.xora.sh/v1/jobs \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "recipe",
"input": {
"url": "https://example.com/raw-video.mp4"
},
"output": {
"format": "mp4"
},
"recipe": {
"name": "compress",
"crf": 28
}
}'
{
"jobId": "01JXYZ1234ABCDEF56789000",
"state": "queued"
}
ParameterTypeRequiredDefaultDescription
namestringYesMust be "compress"
crfnumberNo23Constant Rate Factor — controls quality vs size tradeoff

CRF (Constant Rate Factor) controls the quality-to-size tradeoff on a scale from 0 (lossless) to 51 (worst quality):

CRFQualityTypical use
18Visually losslessArchival, professional
23High qualityDefault, general purpose
28Good qualityWeb delivery, smaller files
32Medium qualityPreviews, bandwidth-constrained
38+Low qualityRough previews only
FormatDescription
mp4H.264 in MP4 container — best compatibility
webmVP8/VP9 in WebM — smaller for web
movH.264 in QuickTime — for Apple/pro workflows
Terminal window
# 1. Create the job
JOB=$(curl -s -X POST https://api.xora.sh/v1/jobs \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "recipe",
"input": { "url": "https://example.com/large-video.mp4" },
"output": { "format": "mp4" },
"recipe": { "name": "compress", "crf": 28 }
}')
JOB_ID=$(echo "$JOB" | jq -r '.jobId')
echo "Created job: $JOB_ID"
# 2. Poll until done
while true; do
STATUS=$(curl -s "https://api.xora.sh/v1/jobs/$JOB_ID" \
-H "Authorization: Bearer YOUR_API_KEY")
STATE=$(echo "$STATUS" | jq -r '.state')
echo "State: $STATE"
[ "$STATE" = "completed" ] || [ "$STATE" = "failed" ] && break
sleep 3
done
# 3. Download
URL=$(echo "$STATUS" | jq -r '.output.signedUrl')
curl -o compressed.mp4 "$URL"