fix: Audio sometimes not added to exports - #214
Open
StickmanRed wants to merge 1 commit into
Open
StickmanRed wants to merge 1 commit into
StickmanRed wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Several projects were reported to be missing certain audios in their
.mp4exports. The bug: aRangeError, originating in Wick.AudioTrack. Further investigation uncovered a discrepancy in the two audio buffers' sizes: the outputdelayedBuffercontained one less element thanoriginalBuffer, causingFloat32Array.setto panic and fail to return the audio data.The
lengthof anAudioBufferequals itssampleRatetimes itsduration.AudioTrack.addStartDelayToAudioBufferuses this to calculate the length of the output buffer:Under certain circumstances, however, the result of these multiplications is subjected to a floating-point error, returning such products as
199998.99999999997instead of199999. AsAudioContext.createBufferrequires an integer length, it discards the decimal part of this result, thus causing theRangeErrorand the audio's disappearance.This PR rounds the length to the nearest integer, eliminating the miscalculation and, hopefully, solving the last audio mystery once and for all.
Testing
.mp4video or a.wavaudio.Checklist