Comments (6)
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.
from wfplayer.
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:
Line 12 in 67cedab
from wfplayer.
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.
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.
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.
I wish I was this naturally polite and friendly as you are
from wfplayer.
Related Issues (20)
- with window.OffscreenCanvas to undefined, options will never be dispatched to drawer.config HOT 6
- Add option for cursor position HOT 2
- +1h audio file destroys the ram HOT 4
- am getting undefinde error first time when i refresh the page HOT 2
- getting audio infinity HOT 1
- Could you please add a speed-changing function? HOT 2
- can you guide me how to create multiple instance of wfplayer at run time? HOT 5
- Add `waveBorder`, `waveBorderColor`, and `waveBorderWidth` Options
- adding grab_start and grab_end events HOT 2
- decodeAudioData crash HOT 1
- loader模块load函数执行错误
- Appending custom headers HOT 1
- Region support HOT 3
- Control audio without audio tag HOT 2
- Webworker vs FFmpeg HOT 1
- npm run dev 报错无法运行 HOT 2
- 这是拼写错误,还是故意写成这个的? HOT 2
- Fill the entire audio width
- 可以发一个2.2.9么😁
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wfplayer.