Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

"MF_E_INVALIDTYPE" error when you record audio to an AVI sink by using MediaCapture API


Symptoms

When you record audio to an AVI sink by using the Windows Runtime Windows.Media.Capture.MediaCapture API together with the AudioEncodingQuality.Auto preset, you may receive an "MF_E_INVALIDTYPE" error message.

↑ Back to the top


Cause

This issue occurs because the AVI sink does not support the requested sampling rate.

Currently, the AVI sink supports only the following sampling rates for audio:

  • 22050 Hz
  • 44100 Hz
  • 48000 Hz
  • 96000 Hz

Some microphones use different sampling rates, such as 16000 Hz. When you try to capture audio into an AVI container with the "Auto" preset, the Windows Runtime layer tries to use recording parameters that match the capture source as closely as possible. This behavior might require unsupported sampling rates.

↑ Back to the top


Workaround

To work around this issue, manually set the sampling rate to 22050 Hz, 44100 Hz, 48000 Hz, or 96000 Hz instead of using the "Auto" preset. You can refer to the following examples in order to set the sampling rate.

For C#
    var mediaCapture = new Windows.Media.Capture.MediaCapture();
await mediaCapture.InitializeAsync();

var encodingProfile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateAvi(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);
// When you record audio to an AVI container, set the "SampleRate" explicitly in order to avoid the "Invalid Type" error.
// The supported values are 22050, 44100, 48000 and 96000.
encodingProfile.Audio.SampleRate = 44100;

var stream = new Windows.Storage.Streams.InMemoryRandomAccessStream();
await mediaCapture.StartRecordToStreamAsync(encodingProfile, stream);

For C++
    m_mediaCapture = ref new Windows::Media::Capture::MediaCapture();
create_task(m_mediaCapture->InitializeAsync()).then([this](task<void> initTask)
{
initTask.get();

auto encodingProfile = Windows::Media::MediaProperties::MediaEncodingProfile::CreateAvi(Windows::Media::MediaProperties::VideoEncodingQuality::Auto);
// When you record audio to an AVI container, set the "SampleRate" explicitly in order to avoid the "Invalid Type" error.
// The supported values are 22050, 44100, 48000 and 96000.
encodingProfile->Audio->SampleRate = 44100;

auto stream = ref new Windows::Storage::Streams::InMemoryRandomAccessStream();
m_mediaCapture->StartRecordToStreamAsync(encodingProfile, stream);
});

For Javascript
    var mediaCapture = new Windows.Media.Capture.MediaCapture();
mediaCapture.initializeAsync().done(function () {
var encodingProfile = Windows.Media.MediaProperties.MediaEncodingProfile.createAvi(Windows.Media.MediaProperties.VideoEncodingQuality.auto);
// When you record audio to an AVI container, set the "SampleRate" explicitly in order to avoid the "Invalid Type" error.
// The supported values are 22050, 44100, 48000 and 96000.
encodingProfile.audio.sampleRate = 44100;

var stream = new Windows.Storage.Streams.InMemoryRandomAccessStream();
mediaCapture.startRecordToStreamAsync(encodingProfile, stream);
},
function () {
document.title = "Error occured";
}, null);

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


Keywords: kbsurveynew, kbtshoot, kbexpertiseadvanced, kb

↑ Back to the top

Article Info
Article ID : 2871818
Revision : 1
Created on : 1/7/2017
Published on : 7/23/2013
Exists online : False
Views : 73