Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HLS): Fix detection of Media Playlist for audio and video only in MP4 #4803

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,23 @@ shaka.hls.HlsParser = class {
if (playlist.segments.length) {
const parsedUri = new goog.Uri(playlist.segments[0].absoluteUri);
const extension = parsedUri.getPath().split('.').pop();
const mimeType = HlsParser.RAW_FORMATS_TO_MIME_TYPES_[extension];
let mimeType = HlsParser.RAW_FORMATS_TO_MIME_TYPES_[extension];
if (mimeType) {
fullMimeType = mimeType;
} else if (extension === 'ts') {
// TODO: Fetch one segment a use the TsParser to analize if there is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you prefer any other way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love fetching segments for analysis. We quit doing it for timestamps, and I don't want to go back.

This is probably not as bad, since it's a media playlist, so we will only ever fetch one segment. I still wish we had another way. But Apple didn't design HLS for MediaSource, so it's tough to make things like this work without probing into the segments.

// video, audio or both.
} else if (extension === 'mp4') {
// TODO: Fetch one segment a use the Mp4Parser to analize if there is
// video, audio or both.
} else if (HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_[extension]) {
mimeType = HlsParser.AUDIO_EXTENSIONS_TO_MIME_TYPES_[extension];
const defaultAudioCodec = this.config_.hls.defaultAudioCodec;
fullMimeType = `${mimeType}; codecs="${defaultAudioCodec}"`;
} else if (HlsParser.VIDEO_EXTENSIONS_TO_MIME_TYPES_[extension]) {
mimeType = HlsParser.VIDEO_EXTENSIONS_TO_MIME_TYPES_[extension];
const defaultVideoCodec = this.config_.hls.defaultVideoCodec;
fullMimeType = `${mimeType}; codecs="${defaultVideoCodec}"`;
}
}

Expand Down