Generate waveform without mediaElement #2677
Replies: 3 comments 3 replies
-
I am going to be doing the same since i will be serving large files(many hours long). Can anyone recommend a Go library that can generate this? I saw a few but am not sure which to pick or whether I need to write my own. |
Beta Was this translation helpful? Give feedback.
-
I was working on a api that allows to generate the PCM data from audio tracks just haven't had much time to spin it up lately. Will share it here once it's available, however you can use something like this: https://github.com/bbc/audiowaveform Run this on the server:
Load the peaks json data on browser: fetch('audiofile.json')
.then(response => {
if (!response.ok) {
throw new Error("HTTP error " + response.status);
}
return response.json();
})
.then(peaks => {
console.log('loaded peaks! sample_rate: ' + peaks.sample_rate);
// load peaks into wavesurfer.js
wavesurfer.load(mediaElt, peaks.data);
})
.catch((e) => {
console.error('error', e);
}); |
Beta Was this translation helpful? Give feedback.
-
It's currently not possible to just render a waveform w/o audio, but this use case makes sense and we could add this option. PRs welcome. The duration can be calculated from the peaks if their sample rate is known. I believe the audiowaveform tool can do that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I followed the instructions on the FAQ page about creating the peak array on the server, but didn’t manage to draw the waveform without the audio file (I need the server to return the created json file only).
Is there a way to it? And also, if I don’t pass the audio file, how would wavesurfer know the size of the audio (in seconds to calculate the width)?
Beta Was this translation helpful? Give feedback.
All reactions