Can't get last timeSlice blob from a streamed wav file
Hi, thanks for creating and maintaining this awesome tool! I have a feature request, or maybe there is a way to do this and I just don't know how.
Per code below, I am streaming a wav file to RecordRTC, and calling ondataavailable's callback every 300ms. This all works fine, except that I'm pretty sure the very last timeSlice before the wav file ends does not trigger ondataavailable's callback, because the last timeSlice is shorter than 300ms perhaps.
As a workaround, I tried using getBlobl() inside recordRTC.stopRecording(), but that returns the entire blob, not just the last timeSlice. That doesn't help me much, because I want to measure real-time streaming metrics with my application through 300ms (or less) blobs.
Is there any way to retrieve the last timeSlice's blob of a stream when it ends? Thanks!!
const audio = new Audio( wav_file );
let stream = audio.captureStream();
console.log("got stream")
const recordRTC = RecordRTC(stream, {
type: "audio",
mimeType: "audio/wav",
recorderType: RecordRTC.StereoAudioRecorder,
bufferSize: 2048,
desiredSampRate: 16000,
numberOfAudioChannels: 1,
timeSlice: 300,
ondataavailable: this.onAudioData,
disableLogs: true,
})
audio.onended = (event) => {
console.log('audio ended');
recordRTC.stopRecording(() => {
let blob = recordRTC.getBlob();
this.onAudioData(blob)
});
};
audio.play().then(() => {
recordRTC.startRecording();
})Source: muaz-khan/RecordRTC