Share via

CreateFileOutputNodeAsync(IStorageFile, MediaEncodingProfile) almost always fails

Jeff Haynes 1 Reputation point
2020-10-28T02:42:44.637+00:00

When using the AudioGraph in UWP, the final output stage is almost completely useless as specifying any encoding except for WAV and MP3 fails.

See this (very old) SO article for more info:

https://stackoverflow.com/questions/33899541/win10-iot-fileoutputnodeasync-cant-use-mediaencodingprofile

Developer technologies | Universal Windows Platform (UWP)
0 comments No comments

1 answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,871 Reputation points
    2020-10-28T06:23:51.367+00:00

    Hello @Jeff Haynes Welcome to Microsoft Q&aA,

    CreateFileOutputNodeAsync(IStorageFile, MediaEncodingProfile) almost always fails

    During testing with code sample it could work well, I suppose you have not specific input device or pass incorrect MediaEncodingProfile , please check this code sample and create MediaEncodingProfile like the following.

    private MediaEncodingProfile CreateMediaEncodingProfile(StorageFile file)  
    {  
        switch(file.FileType.ToString().ToLowerInvariant())  
        {  
            case ".wma":  
                return MediaEncodingProfile.CreateWma(AudioEncodingQuality.High);  
            case ".mp3":  
                return MediaEncodingProfile.CreateMp3(AudioEncodingQuality.High);  
            case ".wav":  
                return MediaEncodingProfile.CreateWav(AudioEncodingQuality.High);  
            default:  
                throw new ArgumentException();  
        }  
    }  
    
    MediaEncodingProfile fileProfile = CreateMediaEncodingProfile(file);  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.