Sunday, July 21, 2024
HomeiOS Developmentjavascript - Error decoding .mov file on ios and macos - DOMException...

javascript – Error decoding .mov file on ios and macos – DOMException when processing audio information in React app


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:

  1. A video file is uploaded.

  2. The video file is transformed to an array buffer.

  3. 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:



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments