windows - IMFMediaSink无法在具有AMD GPU的PC上添加第二个音频输出流

标签 windows audio mp4 ms-media-foundation

我正在尝试创建一个MP4 IMFMediaSink并添加两个编码的音频输入(pcm),以便在mp4文件中可以包含两个音频AAC轨道。

这适用于安装了Intel或NVidia GPU的PC。音频从PCM编码为AAC,并且可以在两个音频层上正常播放。

使用配备AMD GPU(在我的情况下为R9)的PC,尝试添加第二个音频输出流时出现错误。

该错误并不能告诉我太多:

"The request is invalid in the current state."



我的AAC音频MediaType设置如下:
   hr = MFCreateMediaType(&pMediaType);

   hr = pMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);
   hr = pMediaType->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_AAC);
   hr = pMediaType->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, sampleBitSize);
   hr = pMediaType->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, sampleRate);
   hr = pMediaType->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, numChannels);
   hr = pMediaType->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, kAverageBytesPerSec);
   pMediaType->SetBlob(MF_MT_USER_DATA, userData, sizeof(userData));

调用“AddStream()”失败了,第二次,我称之为:
   hr = pSinkWriter->AddStream(pOutputAudioMediaType, &audioLayerIdx);

我的SinkWriter使用以下属性初始化:
   MFCreateAttributes(&pAttributes, 2);
   pAttributes->SetUINT32(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 0);
   pAttributes->SetUINT32(MF_LOW_LATENCY, 1);
   pAttributes->SetGUID(MF_TRANSCODE_CONTAINERTYPE, MFTranscodeContainerType_MPEG4);
   MFCreateSinkWriterFromURL(NULL, pWriteStream, pAttributes, &pSinkWriter);

有人遇到这个问题吗?知道我做错了什么吗?

任何帮助将不胜感激!现在,我一直在努力解决这个问题。

MFTrace(对不起的大转储):
5460,1BC 12:21:04.53040 CKernel32ExportDetours::OutputDebugStringA @ ******************************************************** 111
5460,1BC 12:21:04.53043 CMFReadWriteExportDetours::MFCreateSinkWriterFromURL @ URL: '.mp4', bytestream @00000268FDFBFE90, MF_TRANSCODE_CONTAINERTYPE=MFTranscodeContainerType_MPEG4;MF_READWRITE_DISABLE_CONVERTERS=1;{9C27891A-ED7A-40E1-88E8-B22727A024EE}=1;MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS=0
5460,1BC 12:21:04.53054 COle32ExportDetours::CoCreateInstance @ Created {48E2ED0F-98C2-4A37-BED5-166312DDD83F} MFReadWrite Class Factory (C:\Windows\System32\mfreadwrite.dll) @00000268BA21BCC0 - traced interfaces: IMFReadWriteClassFactory @00000268BA21BCC0, 
5460,1BC 12:21:04.53055 CMFReadWriteClassFactoryDetours::CreateInstanceFromObject @00000268BA21BCC0 Object @00000268FDFBFE90, MF_TRANSCODE_CONTAINERTYPE=MFTranscodeContainerType_MPEG4;MF_READWRITE_DISABLE_CONVERTERS=1;{9C27891A-ED7A-40E1-88E8-B22727A024EE}=1;MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS=0
5460,1BC 12:21:04.53056 CMFAttributesDetours::GetUnknown @00000268C75EDD30 attribute not found guidKey = MF_SINK_WRITER_ASYNC_CALLBACK
5460,1BC 12:21:04.53056 CMFAttributesDetours::GetUINT32 @00000268C75EDD30 attribute not found guidKey = MF_SINK_WRITER_DISABLE_THROTTLING
5460,1BC 12:21:04.53057 CMFAttributesDetours::GetUnknown @00000268C75EDD30 attribute not found guidKey = {2ACF1917-3743-41DF-A564-E727A80EA33E}
5460,1BC 12:21:04.53057 CMFAttributesDetours::GetItemType @00000268C75EDD30 attribute not found guidKey = MF_SINK_WRITER_ASYNC_CALLBACK
5460,1BC 12:21:04.53058 CMFAttributesDetours::GetItemType @00000268C75EDD30 attribute not found guidKey = MF_SINK_WRITER_DISABLE_THROTTLING
5460,1BC 12:21:04.53058 CMFAttributesDetours::GetItemType @00000268C75EDD30 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
5460,1BC 12:21:04.53058 CMFAttributesDetours::GetUINT32 @00000268C75EDD30 attribute not found guidKey = {BDAD7BCA-0E5F-4B10-AB16-26DE381B6293}
5460,1BC 12:21:04.53059 CMFAttributesDetours::GetItemType @00000268C75EDD30 attribute not found guidKey = {39384300-D0EB-40B1-87A0-3318871B5A53}
5460,1BC 12:21:04.53059 CMFAttributesDetours::GetItemType @00000268C75EDD30 attribute not found guidKey = {430847DA-0890-4B0E-938C-054332C547E1}
5460,1BC 12:21:04.53059 CMFAttributesDetours::GetItemType @00000268C75EDD30 attribute not found guidKey = {43AD19CE-F33F-4BA9-A580-E4CD12F2D144}
5460,1BC 12:21:04.53060 CMFAttributesDetours::GetItemType @00000268C75EDD30 attribute not found guidKey = {273DB885-2DE2-4DB2-A6A7-FDB66FB40B61}
5460,1BC 12:21:04.53060 CMFReadWriteClassFactoryDetours::HandleObject @ New sink writer @00000268BA21E980

>>> adding video stream (input H264 ouput H264 : basically a passthrough) stream here....

5460,1BC 12:21:04.53062 CKernel32ExportDetours::OutputDebugStringA @ ******************************************************** 222
5460,1BC 12:21:04.53063 CKernel32ExportDetours::OutputDebugStringA @  
5460,1BC 12:21:04.53068 CMFAttributesDetours::GetUnknown @00000268C75EDD30 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
5460,1BC 12:21:04.53077 CMFSinkWriterDetours::AddStream @00000268BA21E980 Stream Index 0x0, MT: MF_MT_FRAME_SIZE=5497558139600 (1280,720);MF_MT_MPEG_SEQUENCE_HEADER=00 00 01 67 42 c0 1f 95 b0 14 01 6e c0 44 00 00 03 00 04 00 00 03 00 f0 36 82 21 1b 80 00 00 01 68 ca 8f 20 ;MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_SUBTYPE=MEDIASUBTYPE_H264
5460,1BC 12:21:04.53085 CMFSinkWriterDetours::SetInputMediaType @00000268BA21E980 Stream Index 0x0, MT: MF_MT_FRAME_SIZE=5497558139600 (1280,720);MF_MT_MPEG_SEQUENCE_HEADER=00 00 01 67 42 c0 1f 95 b0 14 01 6e c0 44 00 00 03 00 04 00 00 03 00 f0 36 82 21 1b 80 00 00 01 68 ca 8f 20 ;MF_MT_MAJOR_TYPE=MEDIATYPE_Video;MF_MT_FRAME_RATE=128849018881 (30,1);MF_MT_PIXEL_ASPECT_RATIO=4294967297 (1,1);MF_MT_INTERLACE_MODE=2;MF_MT_SUBTYPE=MEDIASUBTYPE_H264

>>> adding FIRST audio stream here....

5460,1BC 12:21:04.53089 CKernel32ExportDetours::OutputDebugStringA @ ******************************************************** 333
5460,1BC 12:21:04.53092 CKernel32ExportDetours::OutputDebugStringA @  
5460,1BC 12:21:04.53095 CMFAttributesDetours::GetUnknown @00000268C75EDD30 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
5460,1BC 12:21:04.53098 CMFSinkWriterDetours::AddStream @00000268BA21E980 Stream Index 0x1, MT: MF_MT_AUDIO_AVG_BYTES_PER_SECOND=16000;MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_USER_DATA=00 00 29 00 00 00 00 00 00 00 00 00 12 10 ;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_AAC
5460,1BC 12:21:04.53101 CKernel32ExportDetours::OutputDebugStringA @ ******************************************************** 444
5460,1BC 12:21:04.53102 CKernel32ExportDetours::OutputDebugStringA @  
5460,1BC 12:21:04.53106 CMFAttributesDetours::GetUnknown @00000268C75EDBB0 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
5460,1BC 12:21:04.53107 CMFAttributesDetours::GetUnknown @00000268C75EDBB0 attribute not found guidKey = MFT_FIELDOFUSE_UNLOCK_Attribute
5460,1BC 12:21:04.53107 CMFAttributesDetours::GetUINT32 @00000268C75EDBB0 attribute not found guidKey = {D91B0085-C86D-4F81-8822-8C68E1D7FA04}
5460,1BC 12:21:04.53108 CMFAttributesDetours::GetUINT32 @00000268C75EDBB0 attribute not found guidKey = {66B16DA9-ADD4-47E0-A16B-5AF1FB483634}
5460,1BC 12:21:04.53108 CMFAttributesDetours::GetUINT32 @00000268C75EDBB0 attribute not found guidKey = {FB683E7E-1CAC-4DBD-9E97-A321EF334D67}
5460,1BC 12:21:04.53109 CMFPlatExportDetours::MFTEnumEx @ Category: MFT_CATEGORY_AUDIO_ENCODER, Flags: 0x00000073, input MT: <NULL>, output MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_SUBTYPE=MFAudioFormat_AAC
5460,1BC 12:21:04.53144 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53154 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53164 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53174 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53184 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53194 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53204 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53214 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53228 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53238 CMFAttributesDetours::GetUINT32 @00000268C75EDEB0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53314 COle32ExportDetours::CoCreateInstance @ Created {00000339-0000-0000-C000-000000000046}  () @000002688EB54A30 - traced interfaces: 
5460,1BC 12:21:04.53389 COle32ExportDetours::CoCreateInstance @ Created {00000339-0000-0000-C000-000000000046}  () @000002688EB55170 - traced interfaces: 
5460,1BC 12:21:04.53434 COle32ExportDetours::CoCreateInstance @ Created {00000339-0000-0000-C000-000000000046}  () @000002688EB57210 - traced interfaces: 
5460,1BC 12:21:04.53446 CMFActivateDetours::GetUINT32 @00000268C7FB49F0 attribute not found guidKey = {3C0FBE52-D034-4115-995D-95B356B9855C}
5460,1BC 12:21:04.53447 CMFActivateDetours::GetUINT32 @00000268C7FB49F0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53447 CMFActivateDetours::GetStringLength @00000268C7FB49F0 attribute not found guidKey = MFT_ENUM_HARDWARE_URL_Attribute
5460,1BC 12:21:04.53450 CMFPlatExportDetours::MFTEnumEx @ Activate 00 @00000268C7FB49F0, MFT_FRIENDLY_NAME_Attribute=Microsoft AAC Audio Encoder MFT;MFT_INPUT_TYPES_Attributes=61 75 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 01 00 00 00 00 00 10 00 80 00 00 aa 00 38 9b 71 ;MFT_TRANSFORM_CLSID_Attribute={93AF0C51-2275-45D2-A35B-F2BA21CAED00};MFT_OUTPUT_TYPES_Attributes=61 75 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 10 16 00 00 00 00 10 00 80 00 00 aa 00 38 9b 71 ;MF_TRANSFORM_FLAGS_Attribute=1;MF_TRANSFORM_CATEGORY_Attribute=MFT_CATEGORY_AUDIO_ENCODER
5460,1BC 12:21:04.53485 COle32ExportDetours::CoCreateInstance @ New MFT @00000268B94D8F48, <NULL>
5460,1BC 12:21:04.53485 COle32ExportDetours::CoCreateInstance @ Created {93AF0C51-2275-45D2-A35B-F2BA21CAED00}  (C:\Windows\System32\mfAACEnc.dll) @00000268B94D8F48 - traced interfaces: IMFTransform @00000268B94D8F48, 
5460,1BC 12:21:04.53486 CMFActivateDetours::GetUnknown @00000268C7FB49F0 attribute not found guidKey = MFT_PREFERRED_ENCODER_PROFILE
5460,1BC 12:21:04.53486 CMFActivateDetours::GetUnknown @00000268C7FB49F0 attribute not found guidKey = MFT_PREFERRED_OUTPUTTYPE_Attribute
5460,1BC 12:21:04.53486 CMFActivateDetours::GetUINT32 @00000268C7FB49F0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
5460,1BC 12:21:04.53486 CMFActivateDetours::ActivateObject @00000268C7FB49F0 New MFT @00000268B94D8F48
5460,1BC 12:21:04.53488 CMFAttributesDetours::GetUnknown @00000268C75EDBB0 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
5460,1BC 12:21:04.53488 CMFAttributesDetours::GetUINT32 @00000268C635CD80 attribute not found guidKey = MF_SA_D3D_AWARE
5460,1BC 12:21:04.53489 CMFAttributesDetours::GetUINT32 @00000268C75EDBB0 attribute not found guidKey = {EACF97AD-065C-4408-BEE3-FDCBFD128BE2}
5460,1BC 12:21:04.53489 CMFAttributesDetours::GetUINT32 @00000268C75EDBB0 attribute not found guidKey = {7B8F32C3-6D96-4B89-9203-DD38B61414F3}
5460,1BC 12:21:04.53489 CMFAttributesDetours::GetUINT32 @00000268C75EDBB0 attribute not found guidKey = {39DBD44D-2E44-4931-A4C8-352D3DC42115}
5460,1BC 12:21:04.53490 CMFAttributesDetours::GetUINT32 @00000268C75EDBB0 attribute not found guidKey = {1B320A5D-DEAB-4986-95A3-950E19B82CB0}
5460,1BC 12:21:04.53491 CMFTransformDetours::SetInputType @00000268B94D8F48 Succeeded MT: <NULL>
5460,1BC 12:21:04.53491 CMFTransformDetours::SetOutputType @00000268B94D8F48 Succeeded MT: <NULL>
5460,1BC 12:21:04.53495 CMFTransformDetours::SetInputType @00000268B94D8F48 Succeeded MT: MF_MT_AUDIO_AVG_BYTES_PER_SECOND=176400;MF_MT_AVG_BITRATE=1411200;MF_MT_AUDIO_BLOCK_ALIGNMENT=4;MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_COMPRESSED=0;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AM_FORMAT_TYPE=FORMAT_WaveFormatEx;MF_MT_AUDIO_PREFER_WAVEFORMATEX=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_PCM
5460,1BC 12:21:04.53497 CMFTransformDetours::SetOutputType @00000268B94D8F48 Succeeded MT: MF_MT_AUDIO_AVG_BYTES_PER_SECOND=16000;MF_MT_AVG_BITRATE=128000;MF_MT_AUDIO_BLOCK_ALIGNMENT=1;MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_COMPRESSED=1;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AM_FORMAT_TYPE=FORMAT_WaveFormatEx;MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION=41;MF_MT_AUDIO_PREFER_WAVEFORMATEX=1;MF_MT_USER_DATA=00 00 29 00 00 00 00 00 00 00 00 00 12 10 ;MF_MT_FIXED_SIZE_SAMPLES=0;MF_MT_AAC_PAYLOAD_TYPE=0;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_AAC
5460,1BC 12:21:04.53498 CMFAttributesDetours::GetUnknown @00000268C75EDBB0 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
5460,1BC 12:21:04.53499 CMFAttributesDetours::GetUINT32 @00000268C635CD80 attribute not found guidKey = {039C0C90-25A9-4DD3-881D-5C1E1534E48B}
5460,1BC 12:21:04.53499 CMFAttributesDetours::GetString @00000268C75EDBB0 attribute not found guidKey = {430847DA-0890-4B0E-938C-054332C547E1}
5460,1BC 12:21:04.53500 CMFAttributesDetours::GetString @00000268C75EDBB0 attribute not found guidKey = {39384300-D0EB-40B1-87A0-3318871B5A53}
5460,1BC 12:21:04.53501 CMFSinkWriterDetours::SetInputMediaType @00000268BA21E980 Stream Index 0x1, MT: MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_PCM

>>> adding SECOND audio stream here....

5460,1BC 12:21:04.53505 CKernel32ExportDetours::OutputDebugStringA @ ******************************************************** 333
5460,1BC 12:21:04.53507 CKernel32ExportDetours::OutputDebugStringA @  
5460,1BC 12:21:04.53509 CMFSinkWriterDetours::AddStream @00000268BA21E980 Failed MT: MF_MT_AUDIO_AVG_BYTES_PER_SECOND=16000;MF_MT_AVG_BITRATE=128000;MF_MT_AUDIO_BLOCK_ALIGNMENT=1;MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_COMPRESSED=1;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AM_FORMAT_TYPE=FORMAT_WaveFormatEx;MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION=41;MF_MT_AUDIO_PREFER_WAVEFORMATEX=1;MF_MT_USER_DATA=00 00 29 00 00 00 00 00 00 00 00 00 12 10 ;MF_MT_FIXED_SIZE_SAMPLES=0;MF_MT_AAC_PAYLOAD_TYPE=0;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_AAC

这是PC上的MFTrace,其中成功添加了第二个音频流:
>> Add the SECOND Audio AAC output... 

8156,2600 14:17:59.04339 CKernel32ExportDetours::OutputDebugStringA @ ******************************************************** 333
8156,2600 14:17:59.04341 CKernel32ExportDetours::OutputDebugStringA @  
8156,2600 14:17:59.04343 CMFAttributesDetours::GetUnknown @000001A843796490 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
8156,2600 14:17:59.04345 CMFSinkWriterDetours::AddStream @000001A8411B0A50 Stream Index 0x2, MT: MF_MT_AUDIO_AVG_BYTES_PER_SECOND=16000;MF_MT_AVG_BITRATE=128000;MF_MT_AUDIO_BLOCK_ALIGNMENT=1;MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_COMPRESSED=1;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AM_FORMAT_TYPE=FORMAT_WaveFormatEx;MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION=41;MF_MT_AUDIO_PREFER_WAVEFORMATEX=1;MF_MT_USER_DATA=00 00 29 00 00 00 00 00 00 00 00 00 12 10 ;MF_MT_FIXED_SIZE_SAMPLES=0;MF_MT_AAC_PAYLOAD_TYPE=0;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_AAC

>> Add the SECOND Audio PCM input... 

    8156,2600 14:17:59.04346 CKernel32ExportDetours::OutputDebugStringA @ ******************************************************** 444
    8156,2600 14:17:59.04347 CKernel32ExportDetours::OutputDebugStringA @  
    8156,2600 14:17:59.04350 CMFAttributesDetours::GetUnknown @000001A8374F10F0 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
    8156,2600 14:17:59.04350 CMFAttributesDetours::GetUnknown @000001A8374F10F0 attribute not found guidKey = MFT_FIELDOFUSE_UNLOCK_Attribute
    8156,2600 14:17:59.04351 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {D91B0085-C86D-4F81-8822-8C68E1D7FA04}
    8156,2600 14:17:59.04351 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {66B16DA9-ADD4-47E0-A16B-5AF1FB483634}
    8156,2600 14:17:59.04351 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {6CE5CB40-ABD3-4A0D-849C-EDF871656C5E}
    8156,2600 14:17:59.04352 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {FB683E7E-1CAC-4DBD-9E97-A321EF334D67}
    8156,2600 14:17:59.04352 CMFAttributesDetours::GetBlobSize @000001A8374F10F0 attribute not found guidKey = {1D39518C-E220-4DA8-A07F-BA172552D6B1}
    8156,2600 14:17:59.04353 CMFPlatExportDetours::MFTEnumEx @ Category: MFT_CATEGORY_AUDIO_ENCODER, Flags: 0x00000073, input MT: <NULL>, output MT: MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_SUBTYPE=MFAudioFormat_AAC
    8156,2600 14:17:59.04354 CMFAttributesDetours::GetUINT32 @000001A8437968B0 attribute not found guidKey = {3C0FBE52-D034-4115-995D-95B356B9855C}
    8156,2600 14:17:59.04356 CMFPlatExportDetours::MFTEnumEx @ Activate 00 @000001A85295DEC0, MFT_FRIENDLY_NAME_Attribute=Microsoft AAC Audio Encoder MFT;MFT_INPUT_TYPES_Attributes=61 75 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 01 00 00 00 00 00 10 00 80 00 00 aa 00 38 9b 71 ;MFT_TRANSFORM_CLSID_Attribute={93AF0C51-2275-45D2-A35B-F2BA21CAED00};MFT_OUTPUT_TYPES_Attributes=61 75 64 73 00 00 10 00 80 00 00 aa 00 38 9b 71 10 16 00 00 00 00 10 00 80 00 00 aa 00 38 9b 71 ;MF_TRANSFORM_FLAGS_Attribute=1;MF_TRANSFORM_CATEGORY_Attribute=MFT_CATEGORY_AUDIO_ENCODER
    8156,2600 14:17:59.04357 CMFAttributesDetours::GetUnknown @000001A8374F10F0 attribute not found guidKey = {2ACF1917-3743-41DF-A564-E727A80EA33E}
    8156,2600 14:17:59.04377 COle32ExportDetours::CoCreateInstance @ New MFT @000001A814078068, <NULL>
    8156,2600 14:17:59.04377 COle32ExportDetours::CoCreateInstance @ Created {93AF0C51-2275-45D2-A35B-F2BA21CAED00}  (C:\Windows\System32\mfAACEnc.dll) @000001A814078068 - traced interfaces: IMFTransform @000001A814078068, 
    8156,2600 14:17:59.04377 CMFActivateDetours::GetUnknown @000001A85295DEC0 attribute not found guidKey = MFT_PREFERRED_ENCODER_PROFILE
    8156,2600 14:17:59.04377 CMFActivateDetours::GetUnknown @000001A85295DEC0 attribute not found guidKey = MFT_PREFERRED_OUTPUTTYPE_Attribute
    8156,2600 14:17:59.04378 CMFActivateDetours::GetUINT32 @000001A85295DEC0 attribute not found guidKey = MFT_CODEC_MERIT_Attribute
    8156,2600 14:17:59.04378 CMFActivateDetours::ActivateObject @000001A85295DEC0 New MFT @000001A814078068
    8156,2600 14:17:59.04379 CMFAttributesDetours::GetUnknown @000001A8374F10F0 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
    8156,2600 14:17:59.04379 CMFAttributesDetours::GetUINT32 @000001A8374F0F10 attribute not found guidKey = MF_SA_D3D_AWARE
    8156,2600 14:17:59.04380 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {EACF97AD-065C-4408-BEE3-FDCBFD128BE2}
    8156,2600 14:17:59.04380 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {7B8F32C3-6D96-4B89-9203-DD38B61414F3}
    8156,2600 14:17:59.04380 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {39DBD44D-2E44-4931-A4C8-352D3DC42115}
    8156,2600 14:17:59.04381 CMFAttributesDetours::GetUINT32 @000001A8374F10F0 attribute not found guidKey = {1B320A5D-DEAB-4986-95A3-950E19B82CB0}
    8156,2600 14:17:59.04382 CMFTransformDetours::SetInputType @000001A814078068 Succeeded MT: <NULL>
    8156,2600 14:17:59.04382 CMFTransformDetours::SetOutputType @000001A814078068 Succeeded MT: <NULL>
    8156,2600 14:17:59.04385 CMFTransformDetours::SetInputType @000001A814078068 Succeeded MT: MF_MT_AUDIO_AVG_BYTES_PER_SECOND=176400;MF_MT_AVG_BITRATE=1411200;MF_MT_AUDIO_BLOCK_ALIGNMENT=4;MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_COMPRESSED=0;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AM_FORMAT_TYPE=FORMAT_WaveFormatEx;MF_MT_AUDIO_PREFER_WAVEFORMATEX=1;MF_MT_FIXED_SIZE_SAMPLES=1;MF_MT_ALL_SAMPLES_INDEPENDENT=1;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_PCM
    8156,2600 14:17:59.04388 CMFTransformDetours::SetOutputType @000001A814078068 Succeeded MT: MF_MT_AUDIO_AVG_BYTES_PER_SECOND=16000;MF_MT_AVG_BITRATE=128000;MF_MT_AUDIO_BLOCK_ALIGNMENT=1;MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_COMPRESSED=1;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AM_FORMAT_TYPE=FORMAT_WaveFormatEx;MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION=41;MF_MT_AUDIO_PREFER_WAVEFORMATEX=1;MF_MT_USER_DATA=00 00 29 00 00 00 00 00 00 00 00 00 12 10 ;MF_MT_FIXED_SIZE_SAMPLES=0;MF_MT_AAC_PAYLOAD_TYPE=0;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_AAC
    8156,2600 14:17:59.04388 CMFAttributesDetours::GetUnknown @000001A8374F10F0 attribute not found guidKey = MF_SOURCE_READER_D3D_MANAGER
    8156,2600 14:17:59.04389 CMFAttributesDetours::GetUINT32 @000001A8374F0F10 attribute not found guidKey = {039C0C90-25A9-4DD3-881D-5C1E1534E48B}
    8156,2600 14:17:59.04390 CMFAttributesDetours::GetString @000001A8374F10F0 attribute not found guidKey = {430847DA-0890-4B0E-938C-054332C547E1}
    8156,2600 14:17:59.04391 CMFAttributesDetours::GetString @000001A8374F10F0 attribute not found guidKey = {39384300-D0EB-40B1-87A0-3318871B5A53}
    8156,2600 14:17:59.04392 CMFSinkWriterDetours::SetInputMediaType @000001A8411B0A50 Stream Index 0x2, MT: MF_MT_AUDIO_NUM_CHANNELS=2;MF_MT_MAJOR_TYPE=MEDIATYPE_Audio;MF_MT_AUDIO_SAMPLES_PER_SECOND=44100;MF_MT_AUDIO_BITS_PER_SAMPLE=16;MF_MT_SUBTYPE=MFAudioFormat_PCM

最佳答案

我看到您已经将MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS设置为false,这不应该知道GPU的加速。

您如何初始化pOutputAudioMediaType?请在此处粘贴您的代码。

我可以分享的调试技巧:
1.使用mftrace记录并与良好情况进行比较。
2.在topoedit中打开您的输入,看看它是否可以在AMD上正确解析拓扑。您可以从WindowsSDK或github archive找到topoedit源代码,并研究其实现方式。

以下是我的代码段,用于设置AAC的输出类型,看看是否有帮助。

HRESULT UpdateAudioOutputTypeAttributes(IMFAttributes *pAttr)  
{  
    HRESULT hr = S_OK;  
    if (!pAttr){  
        hr = E_INVALIDARG;  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetGUID(MF_MT_SUBTYPE, DEFAULT_AUDIO_OUT_FORMAT);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_COMPRESSED, 1);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AVG_BITRATE, DEFAULT_AUDIO_OUT_AVG_BITRATE);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 1);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetGUID(MF_MT_AM_FORMAT_TYPE, FORMAT_WaveFormatEx);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, DEFAULT_AUDIO_OUT_PROFILE_LEVEL);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_FIXED_SIZE_SAMPLES, 0);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AAC_PAYLOAD_TYPE, 0);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, DEFAULT_AUDIO_OUT_NUM_CHANNELS);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, DEFAULT_AUDIO_OUT_SAMPLES_PER_SECOND);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, DEFAULT_AUDIO_OUT_AVG_BYTES_PER_SECOND);  
    }  
    if (SUCCEEDED(hr)){  
        hr = pAttr->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, DEFAULT_AUDIO_OUT_BITS_PER_SAMPLE);  
    }  
    if (SUCCEEDED(hr)){  
        BYTE aacUserData[14] = { 0x00, 0x00, DEFAULT_AUDIO_OUT_PROFILE_LEVEL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };  
        WORD AudioSpecificConfig = 0;  
        AudioSpecificConfig |= 2 << 11;  
        AudioSpecificConfig |= FindFreqIndex(g_pWaveFmt->nSamplesPerSec) << 7;  
        AudioSpecificConfig |= g_pWaveFmt->nChannels << 3;  
        aacUserData[12] = AudioSpecificConfig >> 8;  
        aacUserData[13] = AudioSpecificConfig & 0x00FF;  
        hr = pAttr->SetBlob(MF_MT_USER_DATA, (UINT8*)&(aacUserData), ARRAYSIZE(aacUserData));  
    }  
    return hr;  
}

关于windows - IMFMediaSink无法在具有AMD GPU的PC上添加第二个音频输出流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50032526/

相关文章:

audio - 通过UDP在wifi网络中流音频

ffmpeg - 如何在 1920x1080 视频中使用 "standard PAL"标志

javascript - 如何检测是否在新的 Windows 终端中运行?

c# - Windows UWP应用中的MediaElement无法播放音频

objective-c - 使用AVFoundation在iOS上录制音频样本

ffmpeg2theora 参数超出范围

python - static 子文件夹中的视频不起作用

c - 将数据加载到结构数组 C 时出现段错误

windows - Windows 的 dos2unix 之类的东西吗?

c++ - 如何以编程方式更改非默认声音设备的音量?