No suitable transform was found to encode or decode the content error

≯℡__Kan透↙ 提交于 2021-01-28 23:30:50

问题


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.


回答1:


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.

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.

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:

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;
        }

    }

Here is the complete modified sample: AudioRecorderSample.



来源:https://stackoverflow.com/questions/40013269/no-suitable-transform-was-found-to-encode-or-decode-the-content-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!