I’m engaged on a React utility that processes video information and extracts audio for evaluation. The app works nicely on most platforms, however when I attempt to add and course of a .mov file on an iPhone and on mac, I encounter the next errors:
Error decoding audio information: DOMException
Error processing file: DOMException
The way it works:
-
A video file is uploaded.
-
The video file is transformed to an array buffer.
-
The array buffer is handed to the
decodeAudioData
operate of the Net Audio API to extract audio information.
Under is a part of my code
const extractAudioFromVideo = async (file) => {
return new Promise((resolve, reject) => {
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const reader = new FileReader();
reader.onload = operate () {
const arrayBuffer = reader.consequence;
audioContext.decodeAudioData(arrayBuffer).then((decodedAudioData) => {
const offlineAudioContext = new OfflineAudioContext(
decodedAudioData.numberOfChannels,
decodedAudioData.period * decodedAudioData.sampleRate,
decodedAudioData.sampleRate
);
const soundSource = offlineAudioContext.createBufferSource();
soundSource.buffer = decodedAudioData;
soundSource.join(offlineAudioContext.vacation spot);
soundSource.begin();
offlineAudioContext.startRendering().then((renderedBuffer) => {
const wavBlob = audioBufferToWav(renderedBuffer);
resolve(wavBlob);
}).catch((err) => {
console.error('Error throughout offline audio rendering:', err);
reject(err);
});
}).catch((err) => {
console.error('Error decoding audio information:', err);
reject(err);
});
};
reader.onerror = operate (err) {
console.error('Error studying file:', err);
reject(err);
};
reader.readAsArrayBuffer(file);
});
};
What could possibly be inflicting this DOMException
error, and the way can I resolve it?
Extra Data: