Created
December 30, 2025 04:01
-
-
Save hathibelagal-dev/65fdbdd84cfafbba2845ce9d3a9b6483 to your computer and use it in GitHub Desktop.
Camera shake using FFMPEG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ffmpeg -i input.mp4 -vf " | |
| crop=iw-24:ih-24: | |
| 12+12*(random(1)-0.5): | |
| 12+12*(random(2)-0.5), | |
| scale=iw:ih" output.mp4 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In that “realistic default” command, amplitude is controlled by just one number.
Here’s the command again, annotated:
The one number that matters
This part appears twice (X and Y):
👉 That
12is the shake amplitude (in pixels)It defines how far the frame can move from center
Actual motion range is roughly:
How to change the shake strength
🔹 Subtle, barely noticeable (tripod-like handheld)
Full command:
🔹 Natural handheld (phone / DSLR)
(this is your current setting)
🔹 Strong handheld / action cam
🔹 Violent shake (impact, chaos)
Important: match crop margin to amplitude
You also need enough padding so the frame doesn’t hit edges.
Rule of thumb
So if you use:
Then change:
Example (strong shake, safe margins)
Cheat sheet
Look | Amplitude | Crop margin -- | -- | -- Ultra subtle | 4–6 | 12–16 Natural handheld | 10–14 | 24 Strong handheld | 20–28 | 48 Impact / chaos | 40–60 | 80–120Bonus: make shake “heavier” (less jittery)
If you want weight instead of jitter, lower randomness per second:
instead of:
Example:
This updates shake ~10 times per second, which feels more like a real camera.