Skip to content
HTML/CSS to ImageDocs

Set how long a recording is

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.
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.

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.

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
  • Credits are based on the requested duration_ms, not the length of the finished video.
  • An at_most recording that ends early still uses the credits for its full duration_ms.

See recording credits for the full table.

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" }]
}

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"
}

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.