Lexan
Download audio file from blob
Hello! I'm trying to download an audio file from an open unsecured blob with a URL that starts with blob:https. I'm working on an ASP.NET Core app, .net 7, and Windows both locally and on the host in Azure.
WebClient can't handle the blob prefix.
Does anyone have another approach to how to download the file or get the stream?
8 replies
Convert to wave file gives COMException
Hello! I have rest API using ASP.NET Core app .net 7 and I'm trying to convert a WebM file into a wav file in runtime,
I'm using NAudio and this code :
using (var reader = new MediaFoundationReader(WebMFilePath))
{
WaveFileWriter.CreateWaveFile(WaveFilePath, reader);
}
This works perfectly locally. But when I deploy and run it gives me this exception:
"error": { "message": "The data specified for the media type is invalid, inconsistent, or not supported by this object. (0xC00D36B4)", "exception": "COMException" }
I have no clue on what to do with it or how to move forward.
Any help is appreciated 🙏
37 replies
Convert files from ogg to wav
Hello! I'm using this code to convert a ogg audio file in to a wave audio file. And that works great if the file was downloaded from firefox but not if it's from crome or explorer. The file seem to be 2000 bytes smaller when they are from crome and explorer but I don't know why or how to account for that.
Anyone have a idea on a workaround?
using (FileStream fileIn = new FileStream(oldPath, FileMode.Open)) using (MemoryStream pcmStream = new MemoryStream()) { OpusDecoder decoder = OpusDecoder.Create(48000, 1); OpusOggReadStream oggIn = new OpusOggReadStream(decoder, fileIn); while (oggIn.HasNextPacket) { short[] packet = oggIn.DecodeNextPacket(); if (packet != null) { for (int i = 0; i < packet.Length; i++) { var bytes = BitConverter.GetBytes(packet[i]); pcmStream.Write(bytes, 0, bytes.Length); } } } pcmStream.Position = 0; var wavStream = new RawSourceWaveStream(pcmStream, new WaveFormat(48000, 1)); var sampleProvider = wavStream.ToSampleProvider(); WaveFileWriter.CreateWaveFile16(newPath, sampleProvider); }
10 replies