Skip to content

Function: extractCta608DataFromAv1Sample() ​

ts
function extractCta608DataFromAv1Sample(
   raw, 
   startPos, 
   sampleSize
): number[][];

Defined in: extractCta608DataFromAv1Sample.ts:29

Extracts CTA-608 data from an AV1 (av01) sample.

AV1 has no NAL units, so captions ride in an metadata_itu_t_t35 OBU rather than in an SEI message. The caption payload is unchanged — the same A/53 cc_data() under the same T.35/GA94 identifier that extractCta608DataFromSample reads — so the returned field data feeds Cta608Parser identically.

This is a separate function rather than a codec branch inside extractCta608DataFromSample because the two carriages are framed differently and neither sample is self-identifying. A NAL unit sample puts a fixed-width big-endian length in front of each unit, and that width is only known from lengthSizeMinusOne in the avcC/hvcC config. An AV1 sample uses the low-overhead format, where each OBU carries its own obu_size after the header — and may omit it on the last OBU. Select on the sample entry type (av01) instead.

Parameters ​

raw ​

DataView

The DataView with media data

startPos ​

number

The start position of the sample within the DataView

sampleSize ​

number

The size of the sample in bytes

Returns ​

number[][]

fieldData array containing field 1 and field 2 data arrays

Example ​

ts
it('should extract CTA-608 field data from an AV1 metadata OBU', async () => {
	const file = await readFile(new URL('./fixtures/608_av1.mp4', import.meta.url))
	const { view, mdatBodyStart, samples } = parseSegment(file)

	// The first sample carries the RCL control pair that opens the caption
	const fieldData = extractCta608DataFromAv1Sample(view, mdatBodyStart, samples[0].size)

	deepEqual(fieldData, [[0x94, 0x20], []])
})

A Streaming Video Technology Alliance project.