NAudio throws未找到合适的变换来对生产服务器上的内容进行编码或解码

问题描述 投票:0回答:1

我有一个控制台应用程序正在测试NAudio库,下面的代码在我的本地计算机和测试服务器上工作正常,但在生产服务器上抛出错误

音频文件是.m4a文件

class Program
{
   static void Main(string[] args)
   {
       string audioPath = ConfigurationManager.AppSettings["AudioFile"];
       Console.WriteLine(new AudioFileReader(audioPath).TotalTime.TotalMilliseconds);
       Console.ReadLine();
   }
}

错误消息

System.Runtime.InteropServices.COMException: No suitable tr
ansform was found to encode or decode the content. (Exception from HRESULT: 0xC0
0D5212)
   at NAudio.MediaFoundation.IMFSourceReader.SetCurrentMediaType(Int32 dwStreamI
ndex, IntPtr pdwReserved, IMFMediaType pMediaType)
   at NAudio.Wave.MediaFoundationReader.CreateReader(MediaFoundationReaderSettin
gs settings)
   at NAudio.Wave.MediaFoundationReader.Init(MediaFoundationReaderSettings initi
alSettings)
   at NAudio.Wave.MediaFoundationReader..ctor(String file)
   at NAudio.Wave.AudioFileReader.CreateReaderStream(String fileName)
   at NAudio.Wave.AudioFileReader..ctor(String fileName)
   at NAudioTest.Program.Main(String[] args) in C:\Users\staff\source\repos\NAud
ioTest\NAudioTest\Program.cs:line 15

有关可能导致此错误的任何建议?

c# naudio
1个回答
0
投票
您正在运行的服务器缺少执行该操作所需的Media Foundation编解码器。您必须安装该功能(从内存中,我认为它是“ Desktop Experience”)
© www.soinside.com 2019 - 2024. All rights reserved.