Skip to content

Commit 7ef5e62

Browse files
authored
fix(HLS): Correctly identify webvtt subtitles with cmft extension (#7791)
Fixes #7766
1 parent 1524479 commit 7ef5e62

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/hls/hls_parser.js

+10
Original file line numberDiff line numberDiff line change
@@ -2935,6 +2935,16 @@ shaka.hls.HlsParser = class {
29352935

29362936
if (!mimeType) {
29372937
mimeType = await this.guessMimeType_(type, codecs, segments);
2938+
2939+
// Some manifests don't say what text codec they use, this is a problem
2940+
// if the cmft extension is used because we identify the mimeType as
2941+
// application/mp4. In this case if we don't detect initialization
2942+
// segments, we assume that the mimeType is text/vtt.
2943+
if (type == shaka.util.ManifestParserUtils.ContentType.TEXT &&
2944+
!codecs && mimeType == 'application/mp4' &&
2945+
segments[0] && !segments[0].initSegmentReference) {
2946+
mimeType = 'text/vtt';
2947+
}
29382948
}
29392949

29402950
const {drmInfos, keyIds, encrypted, aesEncrypted} =

test/hls/hls_parser_unit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ describe('HlsParser', () => {
17301730
manifest.addPartialTextStream((stream) => {
17311731
stream.language = 'en';
17321732
stream.kind = TextStreamKind.SUBTITLE;
1733-
stream.mime('application/mp4', '');
1733+
stream.mime('text/vtt', '');
17341734
});
17351735
manifest.sequenceMode = sequenceMode;
17361736
manifest.type = shaka.media.ManifestParser.HLS;

0 commit comments

Comments
 (0)