Different behavior of H.264 encoder MFT on Win7 and Win8

2

Several months have passed since I finished my program which uses H.264 and AAC encoder MFT to convert video files into MP4. While it works well on Win7, when I ran it on Win8 (also tried on Win10 Build 10240) yesterday, I found something different form what I saw on Win7.

My program calls MFT->ProcessInput() to send frames into encoder and calls ProcessOutput after every ProcessInput.

Below is the log generated when I convert a file on Win7. Every time ProcessInput is called, ProcessOutput returns a frame.

Line 178: 00:00:24.562  MAIN  encoding time = 0, duration = 420000
Line 180: 00:00:24.828  MAIN                   sample returned, sample time = 0
Line 185: 00:00:24.875  MAIN  encoding time = 420000, duration = 420000
Line 187: 00:00:25.234  MAIN                   sample returned, sample time = 420000
Line 192: 00:00:25.359  MAIN  encoding time = 840000, duration = 420000
Line 194: 00:00:25.469  MAIN                   sample returned, sample time = 840000
Line 199: 00:00:25.484  MAIN  encoding time = 1260000, duration = 410000
Line 201: 00:00:25.562  MAIN                   sample returned, sample time = 1260000
Line 206: 00:00:25.578  MAIN  encoding time = 1670000, duration = 420000
Line 208: 00:00:25.656  MAIN                   sample returned, sample time = 1670000
Line 213: 00:00:25.672  MAIN  encoding time = 2090000, duration = 420000
Line 215: 00:00:25.781  MAIN                   sample returned, sample time = 2090000
Line 220: 00:00:25.859  MAIN  encoding time = 2510000, duration = 420000
Line 222: 00:00:26.015  MAIN                   sample returned, sample time = 2510000

Below is what I saw when converting same file on Windows 8.1 64bits and Windows 10

Line 196: 00:00:21.187  MAIN  encoding time = 0, duration = 420000
Line 200: 00:00:21.203  MAIN  encoding time = 420000, duration = 420000
Line 204: 00:00:21.234  MAIN  encoding time = 840000, duration = 420000
Line 208: 00:00:21.265  MAIN  encoding time = 1260000, duration = 410000
Line 210: 00:00:21.281  MAIN                   sample returned, sample time = 420000
Line 215: 00:00:21.297  MAIN  encoding time = 1670000, duration = 420000
Line 217: 00:00:21.312  MAIN                   sample returned, sample time = 1260000
Line 222: 00:00:21.343  MAIN  encoding time = 2090000, duration = 420000
Line 224: 00:00:21.359  MAIN                   sample returned, sample time = 840000
Line 230: 00:00:21.375  MAIN  encoding time = 2510000, duration = 420000
Line 232: 00:00:21.406  MAIN                   sample returned, sample time = 2090000
Line 237: 00:00:21.422  MAIN  encoding time = 2930000, duration = 410000
Line 239: 00:00:21.437  MAIN                   sample returned, sample time = 1670000
Line 245: 00:00:21.468  MAIN  encoding time = 3340000, duration = 420000
Line 247: 00:00:21.484  MAIN                   sample returned, sample time = 2930000
Line 252: 00:00:21.515  MAIN  encoding time = 3760000, duration = 420000
Line 254: 00:00:21.515  MAIN                   sample returned, sample time = 2510000

It doesn't matter first frame returns until 4 frames are sent to encoder, what matters to me is that the timestamps of returned frames are not monotonically increasing. (42, 126, 84, 209 ... timestamps is get by calling IMFSample->GetSampleTime()).

After that I ran mftrace on Windows 10 and get this

MFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @08379F88, Time 0ms, Duration 42ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @0C16F1B8, Time 42ms, Duration 42ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @0C16F1B8, Time 84ms, Duration 42ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @0C16F1B8, Time 126ms, Duration 41ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @0C16F1B8, Time 167ms, Duration 42ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @0C16F1B8, Time 209ms, Duration 42ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C Stream ID 0, Sample @08379F88, Time 42ms, Duration 42ms, Buffers 1, Size 24841B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=0 (0,0);{9154733F-E1BD-41BF-81D3-FCD918F71332}=65535;{973704E6-CD14-483C-8F20-C9FC0928BAD5}=0;MFSampleExtension_CleanPoint=1;{B2EFE478-F979-4C66-B95E-EE2B82C82F36}=29 (0,29)
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @0C16F1B8, Time 251ms, Duration 42ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C Stream ID 0, Sample @08379F88, Time 126ms, Duration 42ms, Buffers 1, Size 1152B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=420000 (0,420000);{9154733F-E1BD-41BF-81D3-FCD918F71332}=65535;{973704E6-CD14-483C-8F20-C9FC0928BAD5}=1;MFSampleExtension_CleanPoint=0;{B2EFE478-F979-4C66-B95E-EE2B82C82F36}=29 (0,29)
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessInput @0845899C Stream ID 0, Sample @0C16F1B8, Time 293ms, Duration 41ms, Buffers 1, Size 345600B, 
CMFTransformDetours::ProcessOutput @0845899C Stream ID 0, Sample @08379F88, Time 84ms, Duration 42ms, Buffers 1, Size 20B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=840000 (0,840000);{9154733F-E1BD-41BF-81D3-FCD918F71332}=65535;{973704E6-CD14-483C-8F20-C9FC0928BAD5}=2;MFSampleExtension_CleanPoint=0;{B2EFE478-F979-4C66-B95E-EE2B82C82F36}=29 (0,29)
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT

Lets check ProcessOutput only

CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C Stream ID 0, Sample @08379F88, Time 42ms, Duration 42ms, Buffers 1, Size 24841B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=0 (0,0);{9154733F-E1BD-41BF-81D3-FCD918F71332}=65535;{973704E6-CD14-483C-8F20-C9FC0928BAD5}=0;MFSampleExtension_CleanPoint=1;{B2EFE478-F979-4C66-B95E-EE2B82C82F36}=29 (0,29)
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C Stream ID 0, Sample @08379F88, Time 126ms, Duration 42ms, Buffers 1, Size 1152B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=420000 (0,420000);{9154733F-E1BD-41BF-81D3-FCD918F71332}=65535;{973704E6-CD14-483C-8F20-C9FC0928BAD5}=1;MFSampleExtension_CleanPoint=0;{B2EFE478-F979-4C66-B95E-EE2B82C82F36}=29 (0,29)
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT
CMFTransformDetours::ProcessOutput @0845899C Stream ID 0, Sample @08379F88, Time 84ms, Duration 42ms, Buffers 1, Size 20B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=840000 (0,840000);{9154733F-E1BD-41BF-81D3-FCD918F71332}=65535;{973704E6-CD14-483C-8F20-C9FC0928BAD5}=2;MFSampleExtension_CleanPoint=0;{B2EFE478-F979-4C66-B95E-EE2B82C82F36}=29 (0,29)
CMFTransformDetours::ProcessOutput @0845899C failed hr=0xC00D6D72 MF_E_TRANSFORM_NEED_MORE_INPUT

we can see that the returned timestamps are 42, 126, 84 ...

Because in my program, the muxer (which muxes encoded video and audio data and write them into files) requires monotonically increasing timestamps, the behavior of H.264 encoder MFT on Win8/10 breaks the file conversion.

If anyone is interested in whole mftrace log, I've put it here https://dl.dropboxusercontent.com/u/89678527/mfrelease.log

Thanks for any suggestion.

ms-media-foundation
mft
asked on Stack Overflow Sep 2, 2015 by rhbc73

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0