Giter Site home page Giter Site logo

Comments (6)

yuguaa avatar yuguaa commented on September 20, 2024 1

Thank you for your response. I appreciate it. I understand that I can do it this way. Moreover, I manually modified the drawWave method and simulated audio data using video subtitles' data. The result is that when I simulate a lower bitrate, the project runs smoothly. This might be because my practice project is based on the open-source project Subplayer by the author. However, when rendering the wfplayer with simulated data, it still crashes due to the large amount of data. It seems that I need to do more optimization for the React project. In any case, I appreciate your response.

worker.js
image
image
index.js
image
image

from wfplayer.

zhw2590582 avatar zhw2590582 commented on September 20, 2024

#38 (comment)

You can download this demo to have a look. In fact, Browser crash is not a problem of wfplayer, but a limitation of native AudioContext, this is the process of decoding mp3 audio to pcm audio, which is an unavoidable problem in browsers:

this.audioCtx.decodeAudioData(

from wfplayer.

ExtReMLapin avatar ExtReMLapin commented on September 20, 2024

Alright, but what's weird is I would have expected some kind "decode 4096 bytes by 4096"

I'll try to dive into it tomorrow, thanks for the quick answer

from wfplayer.

yuguaa avatar yuguaa commented on September 20, 2024

This problem also occurs in the project. When decoding, the bit rate is too high, resulting in too much audio sample data, and too little rendering waveform will cause problems. After consideration, we decided to cancel the rendering of the waveform. Based on this, we changed this package., disabled the decoder, other functions are normal, but no waveform diagram

from wfplayer.

ExtReMLapin avatar ExtReMLapin commented on September 20, 2024

You don't need to @yuguaa

You can use ffmpeg WASM to convert the file in browser !

   async videoOrAudioToMP3(ffmpegInstance, videoOrAudioFile) {
      // Prepare the files for ffmpeg.wasm
      //remove all spaces and special characters from the file name
      const videoOrAudioFileName = videoOrAudioFile.name.replace(/[^a-zA-Z0-9.]/g, "");
      const outputFileName = "output_" + videoOrAudioFileName + ".mp3";

      ffmpegInstance.FS("writeFile", videoOrAudioFileName, new Uint8Array(await videoOrAudioFile.arrayBuffer()));

      // Run FFmpeg command to replace the audio track
      this.conversionProgress = 0
      //const self = this;
      await ffmpegInstance.run(
        "-i",
        videoOrAudioFileName,
        "-vn",
        "-acodec",
        "libmp3lame",
        "-ac",
        "1",
        "-ar",
        "16000",
        "-ab",
        "128k",
        outputFileName
      );

      // Read the output file and return it as a File object
      const outputFileBuffer = ffmpegInstance.FS("readFile", outputFileName);
      const outputFileBlob = new Blob([outputFileBuffer.buffer], { type: "audio/mpeg" });
      const outputFile = new File([outputFileBlob], outputFileName, { type: "audio/mpeg" });
      this.conversionProgress = 100


      return outputFile;
    },

from wfplayer.

ExtReMLapin avatar ExtReMLapin commented on September 20, 2024

I wish I was this naturally polite and friendly as you are

from wfplayer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.