Início / Conhecimento / Avançado
Subtitles and Multiple Audio Tracks in HLS
Este artigo está disponível em chinês e inglês; a tradução para português está a caminho.
A complete HLS stream carries more than video and audio — it can include subtitles and multiple audio tracks. All of these are declared in the playlist with the #EXT-X-MEDIA tag.
Declaring alternate media
The master playlist can list different audio tracks (say Chinese and English) and subtitle tracks (such as WebVTT) using #EXT-X-MEDIA, each with TYPE, GROUP-ID, LANGUAGE and NAME attributes. The player uses them to populate its track-selection menu.
Subtitle formats
HLS subtitles usually use WebVTT (.vtt), split into segments and listed in the playlist with timings aligned to the video. Embedded captions and TTML also appear in some setups.
Practical advice
- Keep subtitle tracks on the same time base as the video;
- Give each language a clear NAME and LANGUAGE tag;
- Mark the default track with
DEFAULT=YESfor a better first-play experience.