vidstabdetect measures the shake and vidstabtransform removes it: a 26 px average jump between frames drops to under 2 px. ReelSDK runs both passes for under three quarters of a cent at $0.02 per compute minute; one-pass deshake leaves about 11 px.
Stabilize a shaky video with ffmpeg
Two passes beat one by a wide margin. On ReelSDK they run as 2 jobs that finish in under 20 seconds together, since its ffmpeg has libvidstab and returns the motion file like any other output.
GuidesUpdated
ffmpeg -i shaky.mp4 -vf vidstabdetect=shakiness=8:accuracy=15:result=transforms.trf -f null -vidstabdetect tracks how each frame moved and writes it to transforms.trf. Nothing is encoded, so the output is -f null -. Raise shakiness for rough footage; accuracy is already at its top of 15 by default.
Variations
The other commands you will need
Pass 2: smooth the path and sharpen
vidstabtransformreads the file, smooths the camera path oversmoothingframes each side and moves every frame onto it.unsharprestores the detail lost to the moves. This is the slow pass, over four times as long as pass 1.pass 2 ffmpeg -i shaky.mp4 -vf vidstabtransform=input=transforms.trf:smoothing=30,unsharp=5:5:0.8:3:3:0.4 \ -c:v libx264 -crf 20 -preset veryfast -c:a copy -movflags +faststart stable.mp4One pass with deshake
If your ffmpeg says
No such filter: 'vidstabdetect', it was built without libvidstab.deshakeis built in and needs no file, but it searched only 64 px each way and lost track at times: it left about 11 px of shake on average, and one jump of over 100 px.deshake ffmpeg -i shaky.mp4 -vf deshake=rx=64:ry=64 \ -c:v libx264 -crf 20 -preset veryfast -c:a copy -movflags +faststart deshaked.mp4
The flags
The options that matter
| Flag | What it does | Used here |
|---|---|---|
shakiness=8 | How shaky and quick the camera is, 1 to 10; the default is 5 | Pass 1 |
accuracy=15 | Detection accuracy, 1 to 15; the default is already 15 | Pass 1 |
result | Where pass 1 writes the motion data | Pass 1 |
input | The motion file pass 2 reads | Pass 2 |
smoothing=30 | Frames each side used to smooth the path, here 61 in all | Pass 2 |
optzoom | Zooms in to hide the moving borders; on by default with 1 | Pass 2 |
unsharp | Sharpens after the moves, as the manual recommends | Pass 2 |
rx=64:ry=64 | deshake's search range in pixels, 0 to 64; the default is 16 | Deshake |
Sources: ffmpeg filters: vidstabdetect, vidstabtransform, ffmpeg filters: deshake, checked November 2026.
How we measured it
We made the shaky clip ourselves with one API job: a smaller crop window moved by sine waves over a steady 1080p video. That way we know what steady looks like. The unshaken source moves about 1 px between frames on average, from its own slow pans.
We measured the shift between every pair of frames with OpenCV's phase correlation. The shaky clip averaged 26 px. vidstab brought that under 2 px, close to the source, both locally and on the API; deshake cut it by just over half.
Picking the settings
smoothing=30 averages the camera path over 61 frames, about 2 s at 30 fps. Higher values hold the frame stiller but fight real pans. The manual gives the default as 10; ffmpeg 8.1 reports 15, so set it yourself. Keep optzoom on unless black borders are fine.
The manual adds: "Note the use of the unsharp filter which is always recommended." Every move resamples the picture, and a light unsharp brings the edges back.
Both passes on the API
We checked first: the API's ffmpeg 8.1 has libvidstab, and the pass 1 job returned transforms.trf as a file like any other output. One job runs one ffmpeg command, so the passes are 2 jobs. Here is pass 1; pass 2 is the call in the next block, with that file's URL in inputs.
Two jobs at $0.02 per compute minute cost under three quarters of a cent for this clip; see pricing.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"shaky.mp4": "https://api.reelsdk.com/f/out/job_pz9juy0eeq5ok0r5m0xp/shaky.mp4"
},
"args": [
"-i", "shaky.mp4", "-vf",
"vidstabdetect=shakiness=8:accuracy=15:result=transforms.trf", "-f",
"null", "-"
],
"outputs": ["transforms.trf"]
}'Without installing ffmpeg
The same command as one API call
This is pass 2: transforms.trf from the pass 1 job comes in as an input, and the graph writes the stable clip plus a side-by-side check. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; both passes together took under 20 seconds and cost under three quarters of a cent.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"shaky.mp4": "https://api.reelsdk.com/f/out/job_pz9juy0eeq5ok0r5m0xp/shaky.mp4",
"transforms.trf": "https://api.reelsdk.com/f/out/job_kkslh4ui1p1izxs925t1/transforms.trf"
},
"args": [
"-i", "shaky.mp4", "-filter_complex",
"[0:v]split=2[raw][src];[src]vidstabtransform=input=transforms.trf:smoothing=30,unsharp=5:5:0.8:3:3:0.4,split=2[stable][fixed];[raw]scale=640:360[left];[fixed]scale=640:360[right];[left][right]hstack=2[compare]",
"-map", "[stable]", "-map", "0:a", "-c:v", "libx264", "-crf", "20",
"-preset", "veryfast", "-c:a", "copy", "-movflags", "+faststart",
"stable.mp4", "-map", "[compare]", "-c:v", "libx264", "-crf", "23",
"-preset", "veryfast", "-an", "-movflags", "+faststart", "compare.mp4"
],
"outputs": ["stable.mp4", "compare.mp4"]
}'FAQ
Questions, answered
How do I stabilize a video with ffmpeg?
Run two passes: vidstabdetect writes transforms.trf, then vidstabtransform=input=transforms.trf:smoothing=30 with unsharp encodes the stable video. On our test clip the shift between frames fell from 26 px to under 2 px.
Why does ffmpeg say No such filter: 'vidstabdetect'?
Your build lacks libvidstab, which needs --enable-libvidstab. Use a build that has it, or deshake, which is built in but did far worse on our clip.
Is deshake good enough?
For small shakes, sometimes. On our clip it left a mean shift of about 11 px against under 2 px for vidstab, and it took longer than both vidstab passes together.
Can I run vidstab through an API?
Yes, as 2 jobs. The first writes transforms.trf as an output; the second takes that file's URL as an input and writes the stable video.
- Denoise video with ffmpegRemove grain with hqdn3d, nlmeans, atadenoise or bm3d, and see which one wins on quality, file size and speed.
- Crop a video with ffmpegCut a frame down with crop=w:h:x:y: a centered 9:16 or square crop, a fixed region, and cropdetect to find black bars.
- ffmpeg -filter_complex explainedLabels, commas and semicolons: how a filtergraph wires inputs to outputs, with four working graphs and the errors they fix.
- Put two videos side by side with ffmpegPlace videos next to each other with hstack, on top of each other with vstack, or in a 2x2 grid with xstack, after scaling them to match.
- Speed up or slow down video with ffmpegChange playback speed with setpts for the picture and atempo for the sound, from timelapse to smooth slow motion.
- Video conversionConvert WebM, MKV or MOV to MP4 and back in one ffmpeg call, about a third of a cent for a 30 s clip.
- FFmpeg onlineRun your own ffmpeg command on your files in the browser, free and without installing or uploading anything.
- ffmpeg exited with code 1: Conversion failed!fluent-ffmpeg reports only ffmpeg's exit code and last line. The real cause is in stderr: print it, or use -v error to see it alone.
- ReelSDK vs self-hosted FFmpegTranscoding a minute of 1080p to 720p takes about 24 seconds of compute: about 0.8 cents on ReelSDK, about a tenth of a cent on a busy 4 vCPU box. Below about 11,000 minutes a month, the API costs less than an always-on box.
Sources, checked November 2026
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
