NAudio icon indicating copy to clipboard operation
NAudio copied to clipboard

MediaFoundationReader doesnt work with opus format

Open Mrgaton opened this issue 1 year ago • 2 comments

My code

MediaFoundationReader reader = new MediaFoundationReader(videoPath);

BufferedWaveProvider bufferedWaveProvider = new BufferedWaveProvider(reader.WaveFormat);
bufferedWaveProvider.BufferDuration = TimeSpan.FromMilliseconds(audioBufferLengh * 4);
bufferedWaveProvider.DiscardOnBufferOverflow = true;
bufferedWaveProvider.ReadFully = true;

WaveOut player = new WaveOut();

player.Init(bufferedWaveProvider);

player.Play();

the exception:


Excepcion no controlada: System.Runtime.InteropServices.COMException: No se encontro ninguna transformacion adecuada para codificar o descodificar el contenido. (Excepcion de HRESULT: 0xC00D5212)
   en NAudio.MediaFoundation.IMFSourceReader.SetCurrentMediaType(Int32 dwStreamIndex, IntPtr pdwReserved, IMFMediaType pMediaType)
   en NAudio.Wave.MediaFoundationReader.CreateReader(MediaFoundationReaderSettings settings)
   en NAudio.Wave.MediaFoundationReader.Init(MediaFoundationReaderSettings initialSettings)
   en NAudio.Wave.MediaFoundationReader..ctor(String file)
   en AsciiPlayer.Program.Main(String[] arg) en AsciiPlayer\Program.cs:linea 160

the video:

https://github.com/naudio/NAudio/assets/68958481/4f273ff5-9576-4693-a44b-86b17ed998fe

Mrgaton avatar Feb 11 '24 22:02 Mrgaton

MediaFoundationReader relies on the codecs installed in Windows, so if your version of Windows can't play the file in Windows Media Player then its likely that MediaFoundationPlayer also won't be able to play it

markheath avatar Feb 13 '24 10:02 markheath