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 timestamp offset for raw formats when using segments mode #7819

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,16 @@ shaka.media.MediaSourceEngine = class {
this.audioCompensation_.resolve(compensation);
}
}
const calculatedTimestampOffset = reference.startTime - timestamp;
let realTimestamp = timestamp;
const RAW_FORMATS = shaka.util.MimeUtils.RAW_FORMATS;
// For formats without containers and using segments mode, we need to
// adjust TimestampOffset relative to 0 because segments do not have
// any timestamp information.
if (!this.sequenceMode_ &&
RAW_FORMATS.includes(this.sourceBufferTypes_[contentType])) {
realTimestamp = 0;
}
const calculatedTimestampOffset = reference.startTime - realTimestamp;
const timestampOffsetDifference =
Math.abs(timestampOffset - calculatedTimestampOffset);
if ((timestampOffsetDifference >= 0.001 || seeked || adaptation) &&
Expand Down
16 changes: 11 additions & 5 deletions test/transmuxer/transmuxer_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ describe('Transmuxer Player', () => {
});

it('raw MP3', async () => {
if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"')) {
pending('Codec MP3 in MP4 is not supported by the platform.');
if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"') &&
!await Util.isTypeSupported('audio/mpeg')) {
pending('Codec MP3 is not supported by the platform.');
}
// This tests is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
pending('Disabled on Tizen.');
}
await player.load('/base/test/test/assets/hls-raw-mp3/playlist.m3u8');
await video.play();
Expand Down Expand Up @@ -173,7 +178,7 @@ describe('Transmuxer Player', () => {
}
// This tests is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
return;
pending('Disabled on Tizen.');
}
await player.load('/base/test/test/assets/hls-ts-mp3/manifest.m3u8');
await video.play();
Expand Down Expand Up @@ -377,8 +382,9 @@ describe('Transmuxer Player', () => {
!await Util.isTypeSupported('audio/mpeg')) {
pending('Codec MP3 is not supported by the platform.');
}
if (!shaka.util.Platform.supportsSequenceMode()) {
pending('Sequence mode is not supported by the platform.');
// This tests is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
pending('Disabled on Tizen.');
}

// eslint-disable-next-line max-len
Expand Down
Loading