A region is a box on the video, a few lines high, that cues can be shown in. Its main
use is roll-up captions, as on television, where each new line pushes the older ones
up. Regions are defined in REGION blocks before the first cue.
Region settings
The block is the word REGION on its own line, then settings written
name:value, separated by spaces, tabs or single line breaks. Each may
appear once.
| Setting | Value | Default | Meaning |
|---|---|---|---|
id | text without spaces or --> | empty | The name that cues use in their region setting. Unique in the file. |
width | a percentage | 100% | The width of the region, as a share of the video’s width. |
lines | a whole number | 3 | How many lines of text it holds. The height is 6% of the video’s height per line. |
regionanchor | x%,y% | 0%,100% | A point within the region, as a share of its width and height… |
viewportanchor | x%,y% | 0%,100% | …and the point on the video where that point is placed. The defaults put the bottom-left corner of the region at the bottom-left corner of the video. |
scroll | up | none | New lines appear at the bottom and push older ones up, moving over 0.433 seconds. Any other value means no scrolling. |
How a parser reads region settings
W3C WebVTT sections 6.1 and 6.2. A new region starts with an empty identifier, width 100, 3 lines, region anchor (0, 100), viewport anchor (0, 100) and no scrolling; each setting then replaces its default:
- A token with no colon, or whose first colon is its first or last character, is skipped; names and values are case-sensitive. A repeated setting is not an error: the later one overrides the earlier.
widthand the two anchors take percentages that must match the percentage syntax and be from 0 to 100; otherwise the setting is skipped. An anchor needs a comma, and both numbers must be valid, or the whole anchor is skipped.linesmust contain only ASCII digits (so no sign and no decimal part); it is read as an integer. Otherwise it is skipped.scrolltakes effect only for the exact valueup; anything else leaves it unchanged.idtakes the value as it is. A cue’sregion:setting finds the last region defined so far with that identifier.
Cues in a region
A cue joins a region with region:id. It leaves the region again if it
also has vertical, a line setting, or a size
other than 100%, because there are no vertical regions and a cue placed or sized by
itself is outside any region. Inside a region, a cue’s position is a
share of the region’s width, and its align still applies. The region’s
box hides anything that overflows it (the specification’s note that overflow is hidden),
so lines pushed past the top edge are not shown.
With no scroll value (none), cues do not move from where they were first
painted; a new cue line is added in the empty line closest to the bottom of the region,
and if no line is empty the oldest line is replaced. With scroll:up, lines
are added below existing ones, a line that is removed lets the lines below it move up
into its space, and when there is no room the top-most line is pushed out of the region.
A region is a fixed rendering area, so a single cue with more lines than the region
holds is clipped: at the bottom in a non-scrolling region and at the top in a scrolling
one (W3C WebVTT, the definitions of a region’s lines and scroll values and the note on the scroll setting).
Worked example
WEBVTT
REGION
id:rollup
width:80%
lines:2
regionanchor:50%,100%
viewportanchor:50%,90%
scroll:up
00:00.000 --> 00:04.000 region:rollup
Good evening and welcome.
00:02.000 --> 00:06.000 region:rollup
Tonight's top story: