- Docs
- Parameters
- duration_ms
duration_ms
- Recordings
Set how long a recording is
How it works
Section titled “How it works”duration_ms is the requested length of a recording in milliseconds. It’s required for every recording.
The clock starts when the trigger fires. Loading and preparing the page happens before that, and that time isn’t part of the video.
duration_mode decides what duration_ms means when your actions take more or less time:
duration_mode |
duration_ms is |
|---|---|
at_most (default) |
The longest the video can be. It ends early if the actions finish first. |
fixed |
The exact length of the video. |
at_least |
The shortest the video can be. It runs longer if the actions need it. |
target |
The exact length of the video. The capture is sped up or slowed down to fit. |
Values
Section titled “Values”duration_mode |
Minimum | Maximum |
|---|---|---|
at_most, fixed, at_least |
500 |
30000 |
target |
500 |
90000 |
The API also works out the shortest time your actions could take, counting stall durations, scroll step durations, and click delays. If that’s longer than the mode allows, the request is rejected with a 400.
Default behavior
Section titled “Default behavior”There’s no default. Every recording needs a duration_ms.
The finished video’s length is reported as stored_duration_ms by the Recordings API. It can be shorter than duration_ms in at_most mode, or longer in at_least mode.
Recording credits and billing
Section titled “Recording credits and billing”Credit usage
Section titled “Credit usage”Recordings use 2 credits for the first 5 seconds of duration_ms, plus 1 credit for each additional 5 seconds or part of 5 seconds. target and at_least modes use twice as many.
duration_ms |
at_most / fixed |
target / at_least |
|---|---|---|
5000 |
2 | 4 |
10000 |
3 | 6 |
15000 |
4 | 8 |
30000 |
7 | 14 |
Important notes
Section titled “Important notes”- Credits are based on the requested
duration_ms, not the length of the finished video. - An
at_mostrecording that ends early still uses the credits for its fullduration_ms.
See recording credits for the full table.
Example usage
Section titled “Example usage”Scrolling walkthrough
Section titled “Scrolling walkthrough”A page walkthrough that ends at the bottom of the page, or at 15 seconds:
{ "url": "https://example.com/", "duration_ms": 15000, "actions": [{ "type": "simple_scroll" }]}Fixed-length animation
Section titled “Fixed-length animation”An exactly 6-second clip:
{ "html": "<div class='logo'>Acme</div>", "css": ".logo { animation: spin 2s infinite linear; } @keyframes spin { to { transform: rotate(1turn); } }", "viewport_width": 600, "viewport_height": 600, "duration_ms": 6000, "duration_mode": "fixed"}Long page in a short video
Section titled “Long page in a short video”Capture the whole page, up to 90 seconds, and speed it up to a 20-second video:
{ "url": "https://example.com/blog/long-post", "duration_ms": 20000, "duration_mode": "target", "actions": [{ "type": "simple_scroll" }]}Need help?
Talk to a human. Email support@htmlcsstoimage.com and we’ll help you get started.