YouTube has not published a specification of SBV. This page describes the files YouTube writes, as later tools document them. There is no signature or header; a file starts with its first caption.
One caption
| Line | Content | Notes |
|---|---|---|
| 1 | start,end | Two times separated by a comma, with no spaces. |
| 2 onward | Caption text | One or more lines. As written by YouTube-style files, it ends at a blank line (see Reading below for what Subtitle Edit does with a blank line inside a caption). |
| last | A blank line | Separates this caption from the next. |
Line ends and the file edges
Subtitle Edit’s writer (YouTubeSbv.cs) writes each caption as
start,end, CR LF, the text, CR LF, CR LF, and removes the whitespace at the
very end of the whole file, so the last caption has no blank line after it and the file
ends with its last text line. Multi-line text keeps whatever line ends it holds. The
format has no signature or header; whether a UTF-8 byte order mark is present is up to
the tool, and this source does not write one.
Unlike SRT there is no counter line, no --> and no styling or positioning.
Time format
A time is written H:MM:SS.mmm.
| Part | Digits | Meaning |
|---|---|---|
H | 1 or more | Hours, not zero padded |
MM | 2 | Minutes |
SS | 2 | Seconds |
.mmm | 3 | A full stop and milliseconds |
Reading
YouTube publishes no reader rules. Subtitle Edit’s reader, the one open reader source read for this page, works line by line: each line is first stripped of trailing white space. While it expects a time line, it skips blank lines and counts any other line that is not a time line as an error. Once a time line is read it collects text.
- Time line. It must match
[-]digits:[-]digits:[-]digits, then one of:,,or., then digits (the milliseconds), a comma, and the same again for the end time, with no spaces and no other text. Any number of digits and a minus sign are accepted in every part; each is read as an integer. A full stop is treated as a colon, so0:00:01.400and0:00:01:400read the same. (The writer always writesH:MM:SS.mmm.) The milliseconds are the number as written, so0:00:01.4is 4 ms past the second, not 400. - Where a caption ends. A non-blank line is added to the caption text. A blank line normally ends the caption, but if the line after the blank line is text (not blank, not a whole number and not a time line) the blank line is kept as a line break and the caption goes on; the doubled line break is then reduced to one. So a blank line followed by plain text does not end a caption in this reader, while a blank line followed by a time line, a number or the end of the file does.
- A missing blank line. If a time line appears while text is still being collected and the caption already has text, the caption is closed first, so captions without a separating blank line are still split.
- Text. Kept as written, apart from NUL characters, which become spaces. There is no markup.
Worked example
0:00:01.400,0:00:06.770
Where are we going?
0:00:07.000,0:00:09.250
Somewhere
we have never been.
Not confirmed
Tools differ on minor points. One source adds a caption number before each time line, which does not match the files YouTube writes. The encoding of a file is not stated in it; downloads from YouTube Studio are normally UTF-8. A limit of two text lines is mentioned by converter sites, but is not published by YouTube.