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); }
6 Replies
i would run mediainfo on the two converted files
Thanks! Never used that software but that looks great.
it's just to understand if there's a difference in duration, or maybe one has metadata that the other one doesn't have, or whatever it could be
yeah, I just got a lot more info to work with. So I can try a lot more now. And not just shot in the dark
Thanks for the help!
ffmpeg? not if it's part of some application that you intend to deploy somewhere but
but it'd be much more flexible
I made it work. They was of a different file type.