I’m engaged on a React utility the place I have to extract audio from a video file uploaded by the consumer. The video file is in .mov
format, uploaded from iOS or macOS gadgets. Nevertheless, I’m encountering a DOMException
error through the audio decoding course of.
that is the picture of the error i get
Right here is 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.outcome;
console.log("File learn efficiently. Decoding audio information...");
audioContext.decodeAudioData(arrayBuffer).then((decodedAudioData) => {
console.log("Audio information decoded. Rendering offline audio context...");
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) => {
console.log("Offline audio rendering accomplished.");
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); // That is the place the DOMException is logged
reject(err);
});
};
reader.onerror = operate (err) {
console.error('Error studying file:', err);
reject(err);
};
reader.readAsArrayBuffer(file);
});
};
What I Have Tried:
-
Testing with Completely different Recordsdata:
- The code works completely with
.mp4
recordsdata, however persistently fails with.mov
recordsdata.
- The code works completely with
-
Checking Audio Codec:
- I’ve verified that the
.mov
file makes use of a standard audio codec (AAC).
- I’ve verified that the