[英]How to cut an audio recording in JavaScript
Say I record audio from my microphone, using Recorder.js. 假设我使用Recorder.js从麦克风录制音频。 How can I then trim/crop/slice/cut the recording?
然后如何修剪/裁剪/切片/剪切录音? Meaning, say I record 3.5 seconds, and I want only the first 3 seconds.
意思是说我录制了3.5秒,而我只想要前3秒。 Any ideas?
有任何想法吗?
You can stop the original recording at 3 seconds or use <audio>
element, HTMLMediaElement.captureStream()
and MediaRecorder
to record 3 seconds of playback of the original recording. 您可以在3秒后停止原始记录,或者使用
<audio>
元素, HTMLMediaElement.captureStream()
和MediaRecorder
记录MediaRecorder
回放的3秒。
const audio = new Audio(/* Blob URL or URL of recording */);
const chunks = [];
audio.oncanplay = e => {
audio.play();
const stream = audio.captureStream();
const recorder = new MediaRecorder(stream);
recorder.ondataavailable = e => {
if (recorder.state === "recording") {
recorder.stop()
};
chunks.push(e.data)
}
recorder.onstop = e => {
console.log(chunks)
}
recorder.start(3000);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.