AnvilJSON utilities

Anvil › Docs › /v1/video-size

Video file size API: MB per minute, what fits in free space, bitrate for a target size

Video size is just bitrate times time: MB = Mbps x seconds / 8. A minute of 4K at 30 fps from a phone is about 170 MB in HEVC and 350 MB in H.264; a minute of 1080p is 40 to 60 MB. This endpoint does that maths for typical recording settings, tells you how long fits on a card or phone, and works backwards from a size limit to the bitrate and ffmpeg commands that land under it.

In one line: GET /v1/video-size?preset=p4k_30&codec=hevc&duration=10 returns JSON. No key, CORS on, 60 requests a minute.
GET

/v1/video-size

Video file size: MB for a length, what fits in free space, bitrate and ffmpeg commands for a target size. Change the values and press Send request to call the live API.

Parameters

NameTypeWhat it doesDefault
modestringsize (default) | fits | target | presetssize
presetstringRecording setting: p720_30, p1080_30, p1080_60, p4k_24, p4k_30, p4k_60, slo1080, screen, callp1080_30
codecstringh264 or hevc (HEVC is about half the size)hevc
mbpsnumberCustom bitrate in Mbps (overrides preset)—
durationstringLength: minutes (12), mm:ss (3:45), h:mm:ss (1:20:00) or 1h20m—
free_gbnumbermode=fits: free space in GB—
target_mbnumbermode=target: size limit in MB—
audio_kbpsnumbermode=target: audio bitrate, 0 for none128

Example

Request:

GET https://api.oddlathe.com/v1/video-size?preset=p4k_30&codec=hevc&duration=10

Response (generated by the real code when these docs were last built; random or time-based values will differ for you):

{
 "mode": "size",
 "setting": {
  "preset": "p4k_30",
  "label": "4K, 30 fps",
  "codec": "hevc",
  "mbps": 23
 },
 "seconds": 600,
 "mb": 1725,
 "gb": 1.725,
 "gib": 1.607,
 "mb_per_minute": 172.5,
 "gb_per_hour": 10.35,
 "fat32": {
  "fits": true,
  "max_seconds_one_file": 1494
 },
 "limits": [
  {
   "name": "Typical email attachment limit",
   "mb": 25,
   "fits": false
  },
  {
   "name": "FAT32 single file",
   "mb": 4295,
   "fits": true
  }
 ],
 "summary": "About 1.73 GB for 10 min of 4K, 30 fps (HEVC)."
}

Code examples

curl
curl 'https://api.oddlathe.com/v1/video-size?preset=p4k_30&codec=hevc&duration=10'
JavaScript (browser or Node 18+)
const params = new URLSearchParams({
  preset: "p4k_30",
  codec: "hevc",
  duration: "10"
});
const res = await fetch(`https://api.oddlathe.com/v1/video-size?${params}`);
if (!res.ok) throw new Error((await res.json()).error.message);
const data = await res.json();
console.log(data);
Python (standard library only)
import json, urllib.parse, urllib.request

params = urllib.parse.urlencode({"preset": "p4k_30", "codec": "hevc", "duration": "10"})
url = "https://api.oddlathe.com/v1/video-size?" + params
# Send a User-Agent: the edge network refuses Python's default one.
req = urllib.request.Request(url, headers={"User-Agent": "my-script/1.0"})
with urllib.request.urlopen(req, timeout=10) as r:
    data = json.load(r)
print(data)

When it's useful

  • Upload forms that warn before a clip is too big, or suggest a compression target
  • Storage planners for SD cards, drones, dashcams and phones: how many minutes of 4K fit in 64 GB?
  • Scripts that compress recordings to a size limit with two-pass ffmpeg
  • Teaching how bitrate, codec and resolution trade off against file size

Good to know

  • mode=size (default) takes preset and codec, or a custom mbps, plus duration. Returns mb, gb, gib (as Windows shows it), mb_per_minute, gb_per_hour, a FAT32 4 GB single-file check and a typical 25 MB email-limit check.
  • mode=fits&free_gb=64 lists minutes of every preset that fit, and adds a headline for the preset or mbps you pass.
  • mode=target&target_mb=25&duration=2:00 returns video_kbps (after audio and 3% headroom), a sensible resolution, scale_to and two-pass ffmpeg commands (Linux/macOS and Windows). If it can't fit, ok is false with min_mb_needed.
  • Durations accept minutes (12), 3:45, 1:20:00 or 1h 20m. Sizes are decimal MB and GB, as drives are sold.
  • Preset rates are rounded typical phone and camera figures; real files vary with motion, light and settings.
  • Browser UI: Tooltern video size calculator with the same model and a film-strip view (nothing leaves your device).

How big a video is from a recording setting (or bitrate) and length: MB = Mbps x seconds / 8, with GiB as Windows shows it, whether it fits one FAT32 file and a typical 25 MB email limit. mode=fits says how many minutes of each setting fit in free space, mode=target gives the video bitrate (with 3% headroom), a sensible resolution and two-pass ffmpeg commands to land under a size limit, and mode=presets lists the typical rates. Pure maths; nothing is stored.

Errors

Errors are JSON like {"error": {"code": "…", "message": "…"}}. The ones this endpoint can return:

  • bad_param (400): a value is the wrong type or out of range (the message says which)
  • rate_limited (429): over 60 requests a minute; wait for Retry-After seconds

Questions

How big is a minute of 4K video?

About 170 MB at 4K 30 fps in HEVC and about 350 MB in H.264. <code>/v1/video-size?preset=p4k_30&amp;duration=1</code> returns 172.5 MB.

What bitrate gets a 2 minute video under 25 MB?

About 1,488 kbps video plus 128 kbps audio, which suits 720p. <code>/v1/video-size?mode=target&amp;target_mb=25&amp;duration=2:00</code> also returns the ffmpeg commands.

Why does Windows show a smaller number?

Windows counts in GiB (1,073,741,824 bytes) but labels it GB, so a 4.5 GB file shows as about 4.19 GB. The response includes <code>gib</code>.

Is anything stored?

Never. Pure maths on the query string.

Related endpoints

Prefer a page to an API?

Published · OpenAPI 3.1 spec · Limits and privacy