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: do not wait for audio appends for muxed segments #894

Merged
merged 4 commits into from
Jul 10, 2020

Conversation

brandonocasey
Copy link
Contributor

Description

Noticed that our fmp4/ts mixed content is failing. This is happening because we fire trackinfo on a change when we did not before. The trackinfo that we fire for the ts segment causes us to stall palyback because we wait for audio, but only ever receiver video/combined back from the transmuxer. The fix for muxed fmp4 was only reporting hasVideo. The fix for ts is exactly the same, we should not report hasAudio if the audio and video are muxed together or else we will wait for audio appends that will never come.

Copy link
Contributor

@gesinger gesinger left a comment

Choose a reason for hiding this comment

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

Would be good to add a test for the behavior.

@@ -289,7 +289,7 @@ const transmuxAndNotify = ({

if (probeResult) {
trackInfoFn(segment, {
hasAudio: probeResult.hasAudio,
hasAudio: !isMuxed && probeResult.hasAudio,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a bit strange to me that we are reporting that we don't have audio even though we do. Would it be better to perform the check for isMuxed and hasAudio and separating the behavior at a higher level, so we always report what we do see in the result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a bit strange, I agree, but I don't know if we want to do that or not. I am open to a refactor but lets go over the reasons I have to keep it right now.

The reason we have it setup like this is that we will only ever append to and create a videoBuffer in these situations as videoBuffer will have both codecs: video/mp4;codecs="avc1.4d400d,mp4a.40.2".
This means that our videoBuffer is more of a combined buffer. The segment loader, and anyone else shouldn't care that the segment has audio, since its just a big bundle of data that will only ever be treated as video. We won't ever see any audio data and the audioBuffer won't ever be created. All data will be spit out by the muxer will reported as combined and changed to video

If we want to make such a change I have the code done. I'm just not sure what is best here.

https://github.com/videojs/http-streaming/compare/fix/muxed-no-has-audio...wip/is-muxed?expand=1

Copy link
Contributor

Choose a reason for hiding this comment

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

We should add in @gkatsev too, but I'm inclined to say that if we make changes like this, we should probably do it now. It's hard to read the code as hasAudio having the meaning that it's audio only, rather than a component of muxed.

Copy link
Member

Choose a reason for hiding this comment

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

are you saying to rename hasAudio to something like audioOnlyMedia?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably more of what Brandon prepared in the link, that hasAudio and hasVideo remain descriptors of if the media has audio and video, and isMuxed is passed along to describe whether the content is muxed together or not.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

gkatsev
gkatsev previously approved these changes Jul 8, 2020
Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

Tested and works

@gkatsev gkatsev added this to the 2.1 milestone Jul 8, 2020
gkatsev
gkatsev previously approved these changes Jul 8, 2020

if (hasVideo && hasAudio && !this.audioDisabled_) {
if (hasVideo && hasAudio && !this.audioDisabled_ && !isMuxed) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this check for the opposite? Since if the track has audio and video and audio is not disabled and isMuxed then we should be using the combined buffered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So in the case of isMuxed we will only ever have a videoBuffer so we only want to check videoBuffered. We could forgo this check here and rely on sourceUpdater_. Since sourceUpdater already checks what buffers exist before trying to called buffered on them.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we have alt audio available but muxed at first (an option of demuxed), there will be both audio and video buffers (e.g., the first bipbop in the index page).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah so we will have to check isMuxed here, as in the case of isMuxed we only care about the videoBuffer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so even if there are both audio and video buffers, but the stream is muxed and we're not using an alt audio playlist, then we are only appending to the video buffer, but appending both audio and video? Is there a valid case then for ever using the buffered intersection in a segment loader then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats a good question and the answer might actually be no, maybe a TODO/issue that we need to open.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only set isMuxed when we have a mixed fmp4/ts playlist where the fmp4 part is muxed. In that case we have to mux together video and audio to get it to keep playing.
Normally for muxed content we split it into separate audio and video in the muxer and append to different buffers. In the normal case we will hit these lines.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so the isMuxed is from the result of the transmuxer, telling us whether we've muxed the content together or not. Got it, thanks!

src/segment-loader.js Show resolved Hide resolved
src/segment-loader.js Show resolved Hide resolved
gkatsev
gkatsev previously approved these changes Jul 9, 2020

if (hasVideo && hasAudio && !this.audioDisabled_) {
if (hasVideo && hasAudio && !this.audioDisabled_ && !isMuxed) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, so the isMuxed is from the result of the transmuxer, telling us whether we've muxed the content together or not. Got it, thanks!

src/segment-loader.js Outdated Show resolved Hide resolved
Co-authored-by: Garrett Singer <gesinger@gmail.com>
@gkatsev gkatsev merged commit 406cbcd into main Jul 10, 2020
@gkatsev gkatsev deleted the fix/muxed-no-has-audio branch July 10, 2020 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants