windows 如何让CResamplerMediaObject按预期工作?

gblwokeq  于 2023-03-09  发布在  Windows
关注(0)|答案(1)|浏览(198)

我正在尝试使用CResamplerMediaObject对从DefaultAudioEndpoint捕获的音频进行重新采样,以便将其克隆到我选择的任何其他AudioEndpoint。
但是不管Input/OutputType是什么,它似乎只是通过我输入给它的东西,而没有修改。
如果输入/输出类型如下所示:

inputType()
 WAVEFORMATEXTENSIBLE:
    wFormatTag = 65534
    cbSize = 22
    nAvgBytesPerSec = 384000
    nBlockAlign = 8
    nChannels = 2
    nSamplesPerSec = 48000
    wBitsPerSample = 32
    ext->dwChannelMask = 3
    ext->Samples.wValidBitsPerSample = 32
    ext->Samples.wSamplesPerBlock = 32
    ext->SubFormat = {00000003-0000-0010-8000-00AA00389B71}

 Properties of the media type: 
    MF_MT_AUDIO_NUM_CHANNELS = 2
    MF_MT_AUDIO_SAMPLES_PER_SECOND = 48000
    MF_MT_AUDIO_BLOCK_ALIGNMENT = 8
    MF_MT_AUDIO_AVG_BYTES_PER_SECOND = 384000
    MF_MT_AUDIO_BITS_PER_SAMPLE = 32
    MF_MT_ALL_SAMPLES_INDEPENDENT = 1
    MF_MT_AUDIO_CHANNEL_MASK = 3
    MF_MT_AUDIO_VALID_BITS_PER_SAMPLE = 0

outputType()
 WAVEFORMATEXTENSIBLE:
    wFormatTag = 65534
    cbSize = 22
    nAvgBytesPerSec = 1536000
    nBlockAlign = 32
    nChannels = 8
    nSamplesPerSec = 48000
    wBitsPerSample = 32
    ext->dwChannelMask = 1599
    ext->Samples.wValidBitsPerSample = 32
    ext->Samples.wSamplesPerBlock = 32
    ext->SubFormat = {00000003-0000-0010-8000-00AA00389B71}

 Properties of the media type:
    MF_MT_AUDIO_NUM_CHANNELS = 8
    MF_MT_AUDIO_SAMPLES_PER_SECOND = 48000
    MF_MT_AUDIO_BLOCK_ALIGNMENT = 32
    MF_MT_AUDIO_AVG_BYTES_PER_SECOND = 1536000
    MF_MT_AUDIO_BITS_PER_SAMPLE = 32
    MF_MT_ALL_SAMPLES_INDEPENDENT = 1
    MF_MT_AUDIO_CHANNEL_MASK = 1599
    MF_MT_AUDIO_VALID_BITS_PER_SAMPLE = 0

我希望为每一个长度为8字节的输入帧((wBitsPerSample / 8)* nChannels)得到一个长度为32字节的输出帧,而输出帧仍然是8字节长。
如果我在输出数据中插入丢失的6个字节,它会按预期工作,但这不是重采样器的工作吗?
同样,如果我改变输入或输出的采样率,我希望看到输入和输出数据之间的长度变化,但它保持不变。
您可以找到源代码here
如果有人需要一个工作示例程序,可以使用here

t1rydlwq

t1rydlwq1#

两次使用输入介质类型是可能的原因,并且与您描述的行为相符:

Check( transform()->SetInputType( 0, inputType(), 0 ), "transform()->SetInputType" );
Check( transform()->SetOutputType( 0, inputType(), 0 ), "transform()->SetOutputType" );

相关问题