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

mp4-remuxer / remuxAudio() : recompute mdatSize / dont rely on audioTrack.len #2096

Merged
merged 3 commits into from
Feb 24, 2019

Conversation

mangui
Copy link
Member

@mangui mangui commented Jan 25, 2019

This PR will ...

  • recompute audio mdat size by summing the size of all audio samples, instead of trusting track.len
  • get rid of track.len

Why is this Pull Request needed?

  • this fixes the RangeError exception

Are there any points in the code the reviewer needs to double check?

we might want to clone the problematic stream and add it to the test suite. if fine with the owner. thought ?

Resolves issues:

#2063

Checklist

  • changes have been done against master branch, and PR does not conflict
  • [?] new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

Copy link
Member

@michaelcunningham19 michaelcunningham19 left a comment

Choose a reason for hiding this comment

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

Nice job. LGTM 👍

I'm not able to reproduce the issue with the problem stream with these changes. I also tested out these changes against the demo page assets and some other assets I have access to.

I have one comment/suggestion while reviewing the specifics in the diff, but I'm good with these changes as-is.

Worth noting I tested in Chrome 71 on macOS

if (rawMPEG) {
offset = 0;
} else {
offset = 8;

Choose a reason for hiding this comment

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

Considering the value of rawMPEG isn't changing in this function,

const rawMPEG = !track.isAAC && this.typeSupported.mpeg;

We could initialize the offset value at the time of declaration:

let offset = ( rawMPEG ? 0 : 8 );

This would shorten up the handling here to be something like:

if (mdatSize > 0 && !rawMPEG) {
  mdatSize += 8;
}

Thoughts/concerns?

try {
mdat = new Uint8Array(mdatSize);
mdat = new Uint8Array(rawMPEG ? mdatSize : mdatSize + 8);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can reuse offset here, allocated on L440

Copy link
Member Author

Choose a reason for hiding this comment

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

nice catch

@johnBartos
Copy link
Collaborator

Just merged the Chai PR - you need to use expect instead of assert

recompute it by looping through all samples and summing their individual size

get rid of track.len as it should now be useless

related to #2063
@mangui
Copy link
Member Author

mangui commented Jan 26, 2019

just rebased / squashed.

Copy link
Member

@michaelcunningham19 michaelcunningham19 left a comment

Choose a reason for hiding this comment

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

👍 👍

@johnBartos
Copy link
Collaborator

Going to test it out with some streams which threw this error

@johnBartos johnBartos added this to the 0.13.0 milestone Feb 24, 2019
@johnBartos johnBartos merged commit e8a4085 into master Feb 24, 2019
dyue added a commit to dyue/hls.js that referenced this pull request Mar 9, 2019
* origin/master: (59 commits)
  Change networkDetails type to "unknown".
  mp4-remuxer / remuxAudio() : recompute mdatSize / dont rely on audioTrack.len (video-dev#2096)
  Typo fix for destory -> destroy.
  Change responseType to string
  Callbacks are defined, removing TODO.
  video-devGH-2082: Replacing usage of Array.prototype.find/findIndex (video-dev#2117)
  Reduce GC pressure from ID3._utf8ArrayToStr (video-dev#2035)
  (misc): converting binary search to typescript (video-dev#2129)
  (misc) Removing IE8-specific (dead) vtt/cue code
  Fixed case of 'They use hls.js in production!' header and updated Viacom image link to new domain and using https (video-dev#2127)
  remove events/EventEmitter && move Observer to ts (video-dev#2097)
  Basic typescript of event handler.
  Update webpack to use babel loader with support for TS. (video-dev#2119)
  Allow console statement in test bench and saucelabs code.
  Lint fixes
  Playlist Loader conversion to TypeScript.
  Playlist-loader rename.
  Change IV handling for initSegments to just log a warning.
  Add handling for AES-128 encrypted initialization segments needing IV.
  (misc) Adding ace editor to demo to enable advanced customization (video-dev#2077)
  ...
johnBartos pushed a commit to jwplayer/hls.js that referenced this pull request Apr 19, 2019
johnBartos pushed a commit to jwplayer/hls.js that referenced this pull request May 10, 2019
@robwalch robwalch added this to Done in 0.13.0 Nov 6, 2019
@itsjamie itsjamie deleted the bugfix/2063 branch April 12, 2020 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
0.13.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants