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;