1 year ago
#382178
I. Albuquerque
Convert Blob audio file to mp3 type in typescript
I'm trying to convert a blob audio file to .mp3 type which is generated from MediaRecorder it is returning with webm type and I have tried other types in MimeType(attribute in MediaRecorder to set the type) but they are not supported so I have tried ffmpeg npm library but it was asking for path of the file but i'm not saving it so that also didn't work for me. Any suggestion and answer that will help!!
Here is how i get audio
getAudio(){
navigator.mediaDevices.getUserMedia({ audio: true})
.then( stream => {
console.log(stream)
this.mediaRecord = new MediaRecorder(stream)
this.mediaRecord.ondataavailable = (data: { data: any; }) => {
console.log(data)
this.chunks.push(data.data)
}
this.mediaRecord.onstop = () => {
const blob = new Blob(this.chunks, { type: 'audio/mp3'})
const reader = new window.FileReader()
reader.readAsDataURL(blob)
reader.onloadend = () => {
const teste:any = this.$el.querySelector('#teste')
teste.src = reader.result //render.result e o local onde o audio fica armazenado
this.ArquivoAudio = blob
console.log(reader.result)
}
}
}, err => {
console.log(err)
alert('voce deve permitir a captura de audio')
})
},
typescript
audio
ffmpeg
mp3
html5-audio
0 Answers
Your Answer