【问题标题】:No suitable transform was found to encode or decode the content error找不到合适的转换来编码或解码内容错误
【发布时间】:2016-10-13 05:52:37
【问题描述】:

我正在使用 Windows 10 通用应用程序中的音频录制,我发现代码 here 当我运行该代码时它显示“没有找到合适的转换来编码或解码内容”错误,请在电话中任何人帮助我来解决这个问题。

【问题讨论】:

    标签: c# win-universal-app audio-recording windows-10-universal windows-10-mobile


    【解决方案1】:

    当我运行该代码时,它显示“没有找到合适的转换来编码或解码内容”错误

    如果您引用MediaEncodingProfile.CreateMp3,您将看到以下段落。

    注意虽然在技术上可以调用 CreateMp3,但您不能使用此配置文件将音频转码或编码为 Windows Phone Store 应用程序的 MP3 格式。这是因为 Windows Phone 不附带 MP3 编码器。包含此 API 是为了完整性,并允许您将其与您的应用程序中包含的第 3 方 MP3 编码器一起使用。

    因此,如果您希望此应用与 windows phone 一起使用,则不能使用MediaEncodingProfile.CreateMp3。您可以改用MediaEncodingProfile.CreateM4a(请修改演示中的代码,如下所示):

    MainPage.xaml.cs:

    public sealed partial class MainPage : Page
    {
        MediaCapture capture;
        InMemoryRandomAccessStream buffer;
        bool record;
        string filename;
        string audioFile = "audio.mp4";//originally was audioFIle=".mp3"
        ...
        private async void recordBtn_Click(object sender, RoutedEventArgs e)
        {
            if (record)
            {
                //already recored process
            }
            else
            {
                await RecordProcess();
                //await capture.StartRecordToStreamAsync(MediaEncodingProfile.CreateMp3(AudioEncodingQuality.Auto), buffer);//comment this line out
                await capture.StartRecordToStreamAsync(MediaEncodingProfile.CreateM4a(AudioEncodingQuality.Auto), buffer);//added this line
                if (record)
                {
                    throw new InvalidOperationException();
                }
                record = true;
            }
    
        }
    

    这是修改后的完整示例:AudioRecorderSample

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-14
      • 2016-12-28
      • 1970-01-01
      • 1970-01-01
      • 2012-06-13
      • 1970-01-01
      相关资源
      最近更新 更多