Skip to content

Commit

Permalink
fix(HLS): Correctly identify webvtt subtitles with cmft extension (#7791
Browse files Browse the repository at this point in the history
)

Fixes #7766
  • Loading branch information
avelad authored Dec 23, 2024
1 parent 1524479 commit 7ef5e62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2935,6 +2935,16 @@ shaka.hls.HlsParser = class {

if (!mimeType) {
mimeType = await this.guessMimeType_(type, codecs, segments);

// Some manifests don't say what text codec they use, this is a problem
// if the cmft extension is used because we identify the mimeType as
// application/mp4. In this case if we don't detect initialization
// segments, we assume that the mimeType is text/vtt.
if (type == shaka.util.ManifestParserUtils.ContentType.TEXT &&
!codecs && mimeType == 'application/mp4' &&
segments[0] && !segments[0].initSegmentReference) {
mimeType = 'text/vtt';
}
}

const {drmInfos, keyIds, encrypted, aesEncrypted} =
Expand Down
2 changes: 1 addition & 1 deletion test/hls/hls_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ describe('HlsParser', () => {
manifest.addPartialTextStream((stream) => {
stream.language = 'en';
stream.kind = TextStreamKind.SUBTITLE;
stream.mime('application/mp4', '');
stream.mime('text/vtt', '');
});
manifest.sequenceMode = sequenceMode;
manifest.type = shaka.media.ManifestParser.HLS;
Expand Down

0 comments on commit 7ef5e62

Please sign in to comment.