From 7ef5e6299a513bf3ada457f654939176d2187384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Mon, 23 Dec 2024 10:14:01 +0100 Subject: [PATCH] fix(HLS): Correctly identify webvtt subtitles with cmft extension (#7791) Fixes https://github.com/shaka-project/shaka-player/issues/7766 --- lib/hls/hls_parser.js | 10 ++++++++++ test/hls/hls_parser_unit.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 86e0cef183..726b3a6d23 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -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} = diff --git a/test/hls/hls_parser_unit.js b/test/hls/hls_parser_unit.js index 52bbef8e50..8b5791c3ba 100644 --- a/test/hls/hls_parser_unit.js +++ b/test/hls/hls_parser_unit.js @@ -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;