I want to trim the audio file using JavaScript.

Asked 2 years ago, Updated 2 years ago, 110 views

It creates a voice portfolio where you can post wav, mp3 and so on.I would like to display the file in filereader.result, set the audio data to start with the range of the input element, cut it out for only 20 seconds, and save it to the database.

There was Blob.slice() in a close library that seemed feasible, but the argument was byte specification, not time.You can calculate the file size every second and apply it to the blob.slice argument, but I would like you to tell me about other libraries and tips that can easily trim files.
We look forward to your help.

javascript audio

2022-09-30 15:44

1 Answers

I didn't actually try it, but the library simple-mp3-cutter introduced in How to cut a Audio mp3 Blob in JS in English SO seems to be able to cut mp3 at a specified time.

Cut amp3

cutter.cut(blob, start, end, callback, bitrate);

blobis the audio blob.

startStart time in second.

endEnd time in second.

callbackcallback function (it is not possible to return data from async)

bitrateis optional, default is 192


2022-09-30 15:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.