Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Fix video corruption on rendition switches in IE11 Win 8.1+ and Edge #1259

Merged
merged 7 commits into from
Oct 17, 2017

Conversation

mjneil
Copy link
Contributor

@mjneil mjneil commented Sep 19, 2017

Description

Some browsers (cough IE11 and Edge cough) have a more simple, though still spec compliant, implementation of MediaSourceExtensions compared to other browsers. The main issue with this simpler implementation is that MSE will drop data until the next key frame that comes after the time already sent to the decoder. What this means is you cannot append content that overlaps with the playhead (something videojs-contrib-hls relies on for faster mid-segment quality switching) without the risk of visual corruption since the frames needed to decode the new content at the playhead are dropped before being sent to the decoder.

REQUIRES THE FOLLOWING FOR FULL SUPPORT
videojs/videojs-contrib-media-sources#164
videojs/mux.js#162

Specific Changes proposed

  • Before appending each segment, hls-segment-time-mapping is triggered on the tech for HtmlMediaSource from videojs-contrib-media-sources to listen to so that the VirtualSourceBuffer can properly convert display time to TS time and trim segment appends accordingly.
    • This approach is used so that if native media sources are being used, the event won't have any effect and things will continue working normally.

@@ -1120,6 +1118,15 @@ export default class SegmentLoader extends videojs.EventTarget {
this.trigger('timestampoffset');
}

if (timingInfo && timingInfo.hasMapping) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the calculateSegmentTimeMapping_ function is simple enough, maybe it would be better to change the function to get the segment time mapping and call it again here instead of including the hasMapping property. But either way is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made a function mappingForTimeline

@@ -612,6 +612,13 @@ export class MasterPlaylistController extends videojs.EventTarget {
this.tech_.trigger('hls-reset');
});

this.mainSegmentLoader_.on('segmenttimemapping', (event) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we discussed it, but I'm still uneasy about using the event to communicate with videojs-contrib-media-sources. Although it's better not to add non-standard APIs to videojs-contrib-media-sources, making an event is essentially creating an API for it anyway, and makes the code harder to follow. Although it does help in cases where we don't want to fail on native media sources, I'm thinking that it might be better for us to have a specific method in source updater and contrib-media-sources to accept the data, just to make things easier to follow. Eventually contrib-media-sources will go away, removing the issue.

I do understand the arguments for using the event though (in that we aren't adding a "supported" non standard API to videojs-contrib-media-sources). If we do go with the event route, we should at least add some comments here and in videojs-contrib-media-sources to more easily understand how it is being passed between the two projects.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do understand that the event is more difficult to follow than a direct api, but since we plan on moving away from contrib-media-sources (sooner the better eh) and we already use this event approach else where, I added comments so we can save time on testing a refactor. I've also added comments in the contrib-media-sources pr

@mjneil mjneil merged commit 47d7868 into videojs:master Oct 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants