Skip to content

Commit

Permalink
Adds support for mp4a.40.34 mp3 in HLS
Browse files Browse the repository at this point in the history
When including mp3 files in an HLS stream, the officially supported
codec is mp4a.40.34, according to the HLS FAQ (https://goo.gl/11ZdLh).
This codec string, unfortunately, is not recognized by MSE
implementations on platforms other than Safari.
Therefore, this change omits that codec string.

This change also modifies the start time code in the parser to assume
that mp3 files have a start time of 0.

Closes #1210

Change-Id: I5ccad3f8713fdcafecceff923a4d16ce8fb3ace3
  • Loading branch information
theodab committed Jan 3, 2018
1 parent 21475cf commit a15b4a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,14 @@ shaka.hls.HlsParser.prototype.createVariantsForTag_ = function(tag, playlist) {
height = resBlocks[1];
}

codecs = codecs.filter(function(codec) {
// mp4a.40.34 is a nonstandard codec string that is sometimes used in HLS
// for legacy reasons. It is not recognized by non-Apple MSE.
// See https://bugs.chromium.org/p/chromium/issues/detail?id=489520
// Therefore, ignore this codec string.
return codec != 'mp4a.40.34';
});

// After filtering, this is a list of the media tags we will process to
// combine with the variant tag (EXT-X-STREAM-INF) we are working on.
var mediaTags = Utils.filterTagsByName(playlist.tags, 'EXT-X-MEDIA');
Expand Down Expand Up @@ -1293,6 +1301,10 @@ shaka.hls.HlsParser.prototype.getStartTime_ =
return this.fetchPartialSegment_(segmentRef).then(function(response) {
if (mimeType == 'video/mp4' || mimeType == 'audio/mp4') {
return this.getStartTimeFromMp4Segment_(response.data);
} else if (mimeType == 'audio/mpeg') {
// There is no standard way to embed a timestamp in an mp3 file, so the
// start time is presumably 0.
return 0;
} else if (mimeType == 'video/mp2t') {
return this.getStartTimeFromTsSegment_(response.data);
} else if (mimeType == 'application/mp4' ||
Expand Down

0 comments on commit a15b4a4

Please sign in to comment.