On the supported codecs page, AMR-NB is listed as one of the few encodings that is supported for both encode and decode on a variety of platforms. However, it is conspicuously absent from any of the AudioEncodingProperties
"Create" methods, such as AudioEncodingProperties.CreateMp3
but no corresponding AudioEncodingProperties.CreateAmr
method. All attempts to create an AMR encoder by hand have failed with the classic ambiguous UWP HRESULT-based exception.
For example,
var capture = new MediaCapture();
await capture.InitializeAsync(new MediaCaptureInitializationSettings
{
MediaCategory = MediaCategory.Speech,
StreamingCaptureMode = StreamingCaptureMode.Audio
});
var recordProfile = new MediaEncodingProfile
{
Audio = new AudioEncodingProperties
{
BitsPerSample = 16,
ChannelCount = 1,
SampleRate = 8000,
Subtype = "AMRNB"
}
};
ContainerEncodingProperties containerProperties = new ContainerEncodingProperties
{
Subtype = "AMR" // tried this with every known container
};
recordProfile.Container = containerProperties;
recordProfile.Video = null;
var file = await KnownFolders.VideosLibrary.CreateFileAsync("captured.amr",
CreationCollisionOption.ReplaceExisting);
await capture.StartRecordToStorageFileAsync(recordProfile, file); // this throws
results in System.Exception: 'The requested attribute was not found. (Exception from HRESULT: 0xC00D36E6)'