未找到合适的变换来编码或解码内容错误 [英] No suitable transform was found to encode or decode the content error

查看:101
本文介绍了未找到合适的变换来编码或解码内容错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 10通用应用程序中进行音频录制,我发现代码

I am working with audio recording in windows 10 universal app, i found code here when i run that code it showing "No suitable transform was found to encode or decode the content" error, in phone any one please help me to resolve this issue.

推荐答案

当我运行该代码时,它显示未找到合适的变换来编码或解码内容"错误

when i run that code it showing "No suitable transform was found to encode or decode the content" error

如果您引用

If you refer to MediaEncodingProfile.CreateMp3, you will see the following paragraph.

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

Note While it is technically possible to call CreateMp3, you cannot use this profile to transcode or encode audio into the MP3 format for Windows Phone Store apps. This is because an MP3 encoder is not shipped with Windows Phone. This API is included for completeness and allows you to use it with 3rd party MP3 encoders that you include with your app.

因此,如果您希望该应用程序与Windows Phone配合使用,则不能使用 MediaEncodingProfile.CreateMp3 .您可以使用 MediaEncodingProfile.CreateM4a 代替(请按如下所示修改演示中的代码):

So if you want this app to work with windows phone, you can't use MediaEncodingProfile.CreateMp3. You can use MediaEncodingProfile.CreateM4a instead (please modify the codes in the demo like below):

MainPage.xaml.cs:

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 .

Here is the complete modified sample: AudioRecorderSample.

这篇关于未找到合适的变换来编码或解码内容错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆