Hi,
At first, I wanna thank you for the time you're putting into this project!
I'm trying to record the audio from Chrome, route the WebM opus stream to .NET, convert to another format and re-route the audio to another system, for capturing the audio i'm using something like this:
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
this.mediaRecorder = new MediaRecorder(stream, {
mimeType: 'audio/webm; codecs=opus'
});
this.mediaRecorder.start();
this.isRecording = true;
console.log("Starting media recorder ", this.mediaRecorder);
this.mediaRecorder.ondataavailable = (e) => {
//Do things, convert bytes to base64 and send the audio to the .NET back-end
}
Now, following the examples, I'm using this code in order to extract the opus audio from the WebM stream:
string b64Audio = audioPkt.Audio;
byte[] webmBytes = Convert.FromBase64String(b64Audio);
MemoryStream webmStream = new MemoryStream(webmBytes);
var oggStream = new MemoryStream();
MatroskaDemuxer.ExtractOggOpusAudio(webmStream, oggStream);
I confirm the webm bytes are the same recorded from the js, so no change in data, but in the line MatroskaDemuxer.ExtractOggOpusAudio(webmStream, oggStream);
I got the following error:
System.ArgumentNullException: 'Value cannot be null. Arg_ParamName_Name'
Stack trace:
in Matroska.Muxer.OggOpus.OggOpusAudioStreamDemuxer.CopyTo(MatroskaDocument doc, Stream outputStream, OggOpusAudioStreamDemuxerSettings settings)
in Matroska.Muxer.MatroskaDemuxer.ExtractOggOpusAudio(MatroskaDocument doc, Stream outputStream, OggOpusAudioStreamDemuxerSettings settings)
in PROJECT_NAME.API.Hubs.LiveDataHub.SendAudio(ReceiveAudioDTO audioPkt) in PATH_TO_PROJECT\PROJECT_NAME.API\Hubs\LiveDataHub.cs: riga 70
in Microsoft.Extensions.Internal.ObjectMethodExecutor.<>c__DisplayClass33_0.b__0(Object target, Object[] parameters)
in Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.d__23.MoveNext()
I'm not able to understand what's the cause of the problem looking into the examples and in the various docs of the repo, Am I missing something? Any idea of what can be the issue?