Members
OPUS_AUDIO_SAMPLE_PER_FRAME :number
Retained for backward compatibility. Prefer getPacketSampleCount(), which
handles multi-frame opus packets correctly.
Type:
- number
- Source:
SAMPLES_PER_FRAME_BY_CONFIG_ :Array<number>
Samples per opus frame at 48 kHz, indexed by the 5-bit config field from
the TOC byte. See RFC 6716 §3.1, Table 2.
Type:
- Array<number>
- Source:
Methods
getAudioConfig(metadatanon-null) → {Uint8Array}
Parameters:
| Name | Type | Description |
|---|---|---|
metadata |
shaka.util.TsParser.OpusMetadata |
- Source:
Returns:
- Type
- Uint8Array
getPacketSampleCount(packetnon-null) → {number}
Returns the number of 48 kHz samples represented by an opus packet,
derived from its TOC byte and (for code 3) the frame-count byte.
See RFC 6716 §3.1.
One PES packet in an MPEG-TS opus stream can carry a multi-frame opus
packet (e.g. browser MediaRecorder emits code-3 packets with 3x 20ms
CELT frames = 60ms per packet). Treating one PES packet as one frame's
worth of samples under-counts duration and breaks timeline alignment
in the resulting mp4.
Returned counts are at 48 kHz. This assumes the caller writes the opus
track with a 48 kHz mp4 timescale, which TsParser hardcodes for opus
(RFC 6716: opus always decodes internally at 48 kHz; OpusHead's input
sample rate is informational). If that hardcode ever becomes variable,
scale the return value by (timescale / 48000).
Parameters:
| Name | Type | Description |
|---|---|---|
packet |
Uint8Array | Opus packet starting at the TOC byte. |
- Source:
Returns:
Sample count at 48 kHz.
- Type
- number