Resource
Get it on github
Introduce
Smart Speed Limiter is a lightweight Python script that automatically detects and corrects overspeed issues in JSON‑formatted action sequences. It keeps the movement speed between any two consecutive actions within a safe threshold of 600 units/second by redistributing time and reducing cycle repetition count, never by clipping stroke amplitude — preserving the overall shape and rhythm of the original trajectory as much as possible.
Written by DeepSeek.
Usage
(Python 3.6+ required. If you’re new to Python, just Google it or ask an AI.)
python limit_speed_deepseek.py <input.json> <output.json>
Key Features and How It Works
Funscript Speed Limiter v3.2
Overview
A speed limiter for funscripts that preserves amplitude, rhythm, and total duration. Instead of reducing stroke amplitude, it detects periodic blocks, reduces repetition count, and stretches the remaining cycles to fill the original block duration. Non-periodic overspeed gaps are re-timed, followed by a global speed correction pass.
Usage
python limit_speed_deepseek.py <input.funscript> <output.funscript>
Key Features
- Preserves position amplitude whenever possible.
- Preserves rhythm and total script duration.
- Detects periodic blocks with period sizes
P=2..30. - Reduces repeat count
Kand stretches cycles to lower speed. - Handles short non-periodic overspeed gaps up to
MAX_GAP_PTS. - Applies global overspeed correction only above
MAX_SPEED + SPEED_TOL. - Iterates global correction up to
MAX_ITERtimes. - Cleans timestamps, removes duplicates, and enforces strictly increasing time.
- Restores original first/last timestamps and positions.
- Provides optional debug validation for outliers and overspeed segments.
How It Works
-
Load and preprocess
Sort actions byatandpos, drop near-duplicate points, and normalize same-timestamp conflicts. -
Detect periodic blocks
Scan for repeated cycles where positions match withinPOS_TOLand relative timing matches withinTIME_RATIO_TOL. Extend each match to count total repeatsK.P=2requires more repeats to avoid false positives. -
Limit periodic blocks
For each detected block, try reducingKtoK_new. Rescale the firstK_newcycles uniformly into the original block durationT_block. This lowers speed without changing stroke amplitude. If even one cycle cannot fit, keep the original block. -
Handle non-periodic gaps
For uncovered overspeed segments with at mostMAX_GAP_PTSpoints, compute minimum required time per segment usingMAX_SPEED, then distribute remaining slack proportionally to original segment durations. -
Global speed correction
After merging all segments, correct only speeds aboveMAX_SPEED + SPEED_TOL. Push later timestamps forward as needed, then rescale total duration back to the original duration. Repeat up toMAX_ITERtimes. -
Final cleanup and output
Sort, deduplicate, enforce increasing timestamps, restore original first/last points, and write compact JSON.
Parameters
| Parameter | Default | Purpose |
|---|---|---|
MAX_SPEED |
600 |
Maximum speed in pos/s |
SPEED_TOL |
10 |
Global fix tolerance; only correct speeds above MAX_SPEED + SPEED_TOL |
TIME_RATIO_TOL |
0.15 |
Relative timing tolerance for period matching |
MIN_PERIOD_SEGS |
2 |
Minimum period segment count |
MAX_PERIOD_SEGS |
30 |
Maximum period segment count |
MIN_REPEATS |
3 |
Minimum repeats for normal periods |
MIN_REPEATS_P2 |
5 |
Minimum repeats for P=2 periods |
POS_TOL |
0.5 |
Position tolerance for period matching |
MAX_GAP_PTS |
15 |
Maximum gap size eligible for re-timing |
MAX_ITER |
8 |
Maximum global correction iterations |
DEBUG |
False |
Enable verbose validation output |
Notes
- The script cannot create time. If the original duration is insufficient, some overspeed may remain.
- Speeds up to
MAX_SPEED + SPEED_TOLare treated as acceptable to avoid unnecessary micro-adjustments. - Best suited for regular repetitive scripts, but designed to safely handle irregular segments.
- Output preserves the original first/last timestamps and positions.
Comparison of Results
Before
![]()
After
![]()
Before
After
Compare
More compare and detail
For quite a long time, I had made quite a few iterations to my script speed-limiting tool, but they were not released. So this looks like a major update. In this version, it has become more stable and fixed more issues that existed in previous versions, such as inaccurate recognition of repeated waveforms, corrupting actions, and so on.
In my latest version, I tested it across multiple scripts, including some with very complex actions, random scripts, scripts with a random mix of irregular and regular patterns, and scripts with continuous overspeed. In these tests, the tool performed very well.
I recommend that you use this new version of the script. Below are some examples I used for testing. You can use my tool to process the original scripts and get the same results.
In the case of this random waveform, its processing effect is as follows.
Before
cassie-cage-ponytail-facefuck-alt_1080p.funscript (1.2 KB)
After
output.funscript (1023 Bytes)
In the case of complex interleaved actions, its processing effect is as follows:
Before
1000 Bekscript special HMV (Hardcore).funscript (52.2 KB)
After
output.funscript (38.0 KB)
In cases where regular and irregular patterns alternate and mix randomly, its processing effect is as follows:
Before
zzbusio - I love HENTAI #9 (Hardcore).funscript (22.4 KB)
After
output.funscript (22.3 KB)
The overspeed value of 613 here is because 610 is the maximum tolerance, while the 3 is a rounding precision issue; in practice, it still meets the requirements.If you are still not satisfied with this value, you can make adjustments in the tool.
Before
overspeed.funscript (1.3 KB)
After
output.funscript (537 Bytes)
Apology
I sincerely apologize to anyone who was hurt by my previous behavior. Since then, I’ve been working hard on this issue and have gone through many iterations. With this latest version, I believe it now delivers what I originally promised, so I’ve updated the post to reflect this update.






