title: Capture audio with AMR-NB encoding in UWP?
body: <p>On the <a href="https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/supported-codecs" rel="nofollow noreferrer">supported codecs</a> 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 <code>AudioEncodingProperties</code> &quot;Create&quot; methods, such as <code>AudioEncodingProperties.CreateMp3</code> but no corresponding <code>AudioEncodingProperties.CreateAmr</code> method.  All attempts to create an AMR encoder by hand have failed with the classic ambiguous UWP HRESULT-based exception.</p>
  <p>For example,</p>
  <pre class="lang-cs prettyprint-override"><code>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 = &quot;AMRNB&quot;
      }
  };
  
  ContainerEncodingProperties containerProperties = new ContainerEncodingProperties
  {
      Subtype = &quot;AMR&quot; // tried this with every known container
  };
  
  recordProfile.Container = containerProperties;
  recordProfile.Video = null;
  
  var file = await KnownFolders.VideosLibrary.CreateFileAsync(&quot;captured.amr&quot;,
      CreationCollisionOption.ReplaceExisting);
  await capture.StartRecordToStorageFileAsync(recordProfile, file); // this throws
  
  </code></pre>
  <p>results in <code>System.Exception: 'The requested attribute was not found. (Exception from HRESULT: 0xC00D36E6)'</code></p>