-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
the total duration wavesurfer is giving me is wrong #3707
Comments
Hey @Johnrobmiller, were you able to find a workaround for this? Running into the same issue |
I try to reproduce with below code audioEl.value.onloadedmetadata = () => {
console.log("audioEl", audioEl.value?.duration);
};
const audioContext = new AudioContext();
const audioBuffer = await fetch(audioURL)
.then((value) => value.blob())
.then((blob) => blob.arrayBuffer())
.then((buffer) => audioContext.decodeAudioData(buffer));
console.log("audioBuffer ", audioBuffer.duration); and result is
found that the result of audioContext is right, and another interesting discovery is, when I change the format from mp3 to wav, the result of audioEl and audioContext will be same. wavesurfer.js/src/wavesurfer.ts Lines 526 to 533 in 5f32d82
wavesurfer tends to use the built-in duration of the audio element, which leads to inaccuracies. maybe we can exchange their order? |
maybe this info can help HTML audio object reporting wrong file duration |
I have a audio file that is exactly 6.84 seconds long. I use js to and my OS to confirm that it exactly that duration. However, when I load it into Wavesurfer and call
ws.getDuration()
, wavesurfer is wrongly reporting that it is 6.81795 seconds long. This was causing a bug in my app that was difficult to troubleshoot.The duration that wavesurfer is outputting ought to be exactly the same as the actual duration of the audio file.
Note: wavesurfer gets the duration wrong even if it is manually set in the options, as noted here #3656
The text was updated successfully, but these errors were encountered: