Part of the
@remotion/media-utils package of helper functions.
Takes an audio
src, loads it and returns data and metadata for the specified source.
A string pointing to an audio asset.
Promise<AudioData> - object with information about the audio data:
Float32Arrayan array with waveform information for each channel.
numberHow many samples per second each waveform contains.
numberThe duration of the audio in seconds.
numberThe number of channels contained in the audio file. This corresponds to the length of the
stringUnique identifier of this audio data fetching call. Other functions can cache expensive operations if they get called with the same resultId multiple times.
booleanWhether the audio was imported locally or from a different origin.
This function is memoizing the results it returns.
If you pass in the same argument to
src multiple times, it will return a cached version from the second time on, regardless of if the file has changed. To clear the cache, you have to reload the page.
If you need only the duration, prefer
getAudioDuration() which is faster because it doesn't need to read waveform data.