ogg to mp3 using NAudio MFT

1

Here, I am having a problem while converting ogg file to mp3 format. Reading ogg file is done successfully but while encoding it is throwing exception like,"Exception from HRESULT: 0xC00D3E85". Presently I am working on windows server 2012(64 bit).

public byte[] DecodeOGG(byte[] data,string trgtfilename,int bitrate)
{      
   byte[] dt = null;
   NVorbis.NAudioSupport.VorbisWaveReader vr = null;
   using(MemoryStream ms = new MemoryStream(data))
   {
      ms.Position = 0;
      vr = new NVorbis.NAudioSupport.VorbisWaveReader(ms);
   }                        
   var samp = new SampleChannel(vr);
   var ws = new SampleToWaveProvider16(samp);
   MediaFoundationEncoder.EncodeToMp3(ws, trgtfilename, bitrate);
}
c#-4.0
mp3
naudio
ogg
oggvorbis
asked on Stack Overflow Nov 23, 2013 by sainath sagar

1 Answer

1

You need to call MediaFoundationInterop.Startup() somewhere in your application. NAudio may be updated in the future to call this automatically.

answered on Stack Overflow Nov 25, 2013 by Mark Heath

User contributions licensed under CC BY-SA 3.0