首页 > 解决方案 > WMF EVR stops sending MEStreamSinkRequestSample event ~7 seconds into the live stream

问题描述

I'm writing a WMF custom media source. This source gets h264 packets from an RTSP stream(using FFMPeg 4.1), and sends them to a decoder and renders them to screen with an EVR. It also sends them to an encoder, and a file writer

For the first ~7 seconds video looks good after ~7 seconds FPS changes from ~30 to ~2 and the EVR shows an old image as an artifact (it is shown instead of the missing frames). The recorded video looks fine.

running MFTrace I found that the renderer stops sending the MEStreamSinkRequestSample, so the source that have data to send (and raises MEMediaSample as before) does not send the sample. The samples only reach the decoder’s ProcessInput, and I can’t see the ProcessOutput calls. According to my logs there are no B frames (pts == dts) and both are monotonic with normal looking timestamps

These are the log lines for the last frame that reached the EVR

    Line 149066: 552,1AA8 13:03:30.50129 CMFSourceReaderCallbackDetours::OnReadSample @0000027792F818B0 Stream index 0x0 Sample @000002779DB2FF80, Time 7266ms, Duration 33ms, Buffers 1, Size 620B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=72666778 (0,72666778);MFSampleExtension_Token=@000002779DB1FA60;MFSampleExtension_DeviceTimestamp=72666778 (0,72666778);MFSampleExtension_CleanPoint=0;MFSampleExtension_Interlaced=0
    Line 149100: 552,3F90 13:03:30.50182 CMFMediaStreamDetours::HandleEvent @0000027792FF7930 Sample @000002779DB2FF80, Time 7266ms, Duration 33ms, Buffers 1, Size 620B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=72666778 (0,72666778);MFSampleExtension_Token=@000002779DB1FA60;MFSampleExtension_DeviceTimestamp=72666778 (0,72666778);MFSampleExtension_CleanPoint=0;MFSampleExtension_Interlaced=0
    Line 149174: 552,3F90 13:03:30.50210 CMFTransformDetours::ProcessInput @0000027790451EE0 Stream ID 0, Sample @000002779DB2FF80, Time 7266ms, Duration 33ms, Buffers 1, Size 620B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=72666778 (0,72666778);MFSampleExtension_Token=@000002779DB1FA60;MFSampleExtension_DeviceTimestamp=72666778 (0,72666778);MFSampleExtension_CleanPoint=0;MFSampleExtension_Interlaced=0
    Line 166573: 552,A50 13:03:31.60248 CMFTransformDetours::ProcessOutput @0000027790451EE0 Stream ID 0, Sample @000002779DB2F980, Time 7266ms, Duration 33ms, Buffers 1, Size 1382400B, {19124E7C-AD4B-465F-BB18-20186287B6AF}=;{424C754C-97C8-48D6-8777-FC41F7B60879}=@0000000000000000;{79EA74DF-A740-445B-BC98-C9ED1F260EEE}=0;MFSampleExtension_CleanPoint=1;MFSampleExtension_Discontinuity=0;MFSampleExtension_Interlaced=0;{B4DD4A8C-0BEB-44C4-8B75-B02B913B04F0}=0
    Line 166728: 552,A50 13:03:31.60276 CMFTransformDetours::ProcessInput @000002779041B330 Stream ID 0, Sample @000002779DB2F980, Time 7266ms, Duration 33ms, Buffers 1, Size 1382400B, {19124E7C-AD4B-465F-BB18-20186287B6AF}=;{424C754C-97C8-48D6-8777-FC41F7B60879}=@0000000000000000;{73A954D4-09E2-4861-BEFC-94BD97C08E6E}=83666778 (0,83666778);{79EA74DF-A740-445B-BC98-C9ED1F260EEE}=0;MFSampleExtension_Token=@0000000000000000;MFSampleExtension_DeviceTimestamp=83666778 (0,83666778);MFSampleExtension_CleanPoint=1;MFSampleExtension_Discontinuity=0;MFSampleExtension_Interlaced=0;{B4DD4A8C-0BEB-44C4-8B75-B02B913B04F0}=0
    Line 166853: 552,A50 13:03:31.60482 CMFTransformDetours::ProcessOutput @000002779041B330 Stream ID 0, Sample @000002779DB25BC0, Time 7266ms, Duration 33ms, Buffers 1, Size 1843200B, MFSampleExtension_CleanPoint=1;MFSampleExtension_Interlaced=0
    Line 166905: 552,A50 13:03:31.60500 CMFStreamSinkDetours::ProcessSample @000002779045A878 Sample @000002779DB25BC0, Time 7266ms, Duration 33ms, Buffers 1, Size 1843200B, {19124E7C-AD4B-465F-BB18-20186287B6AF}=;{424C754C-97C8-48D6-8777-FC41F7B60879}=@0000000000000000;{73A954D4-09E2-4861-BEFC-94BD97C08E6E}=83666778 (0,83666778);{79EA74DF-A740-445B-BC98-C9ED1F260EEE}=0;MFSampleExtension_Token=@000002779DB1F6A0;MFSampleExtension_DeviceTimestamp=83666778 (0,83666778);MFSampleExtension_CleanPoint=1;MFSampleExtension_Discontinuity=0;MFSampleExtension_Interlaced=0;{B4DD4A8C-0BEB-44C4-8B75-B02B913B04F0}=0
    Line 166909: 552,A50 13:03:31.60503 CMFTransformDetours::ProcessInput @0000027790455960 Stream ID 0, Sample @000002779DB25BC0, Time 7266ms, Duration 33ms, Buffers 1, Size 1843200B, {19124E7C-AD4B-465F-BB18-20186287B6AF}=;{424C754C-97C8-48D6-8777-FC41F7B60879}=@0000000000000000;{73A954D4-09E2-4861-BEFC-94BD97C08E6E}=83666778 (0,83666778);{79EA74DF-A740-445B-BC98-C9ED1F260EEE}=0;MFSampleExtension_Token=@000002779DB1F6A0;MFSampleExtension_DeviceTimestamp=83666778 (0,83666778);MFSampleExtension_CleanPoint=1;MFSampleExtension_Discontinuity=0;MFSampleExtension_Interlaced=0;{B4DD4A8C-0BEB-44C4-8B75-B02B913B04F0}=0
    Line 166918: 552,A50 13:03:31.60510 CMFTransformDetours::ProcessOutput @0000027790455960 Stream ID 0, Sample @000002779045EF00, Time 7266ms, Duration 33ms, Buffers 1, Size 409920B, , Duration 33ms, Buffers 1, Size 409920B,

And there are the log lines that end with the decoder

    Line 149726: 552,260 13:03:30.53399 CMFSourceReaderCallbackDetours::OnReadSample @0000027792F818B0 Stream index 0x0 Sample @000002779DB2F500, Time 7300ms, Duration 33ms, Buffers 1, Size 662B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=73000000 (0,73000000);MFSampleExtension_Token=@000002779DB1F640;MFSampleExtension_DeviceTimestamp=73000000 (0,73000000);MFSampleExtension_CleanPoint=0;MFSampleExtension_Interlaced=0
    Line 149760: 552,3F90 13:03:30.53446 CMFMediaStreamDetours::HandleEvent @0000027792FF7930 Sample @000002779DB2F500, Time 7300ms, Duration 33ms, Buffers 1, Size 662B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=73000000 (0,73000000);MFSampleExtension_Token=@000002779DB1F640;MFSampleExtension_DeviceTimestamp=73000000 (0,73000000);MFSampleExtension_CleanPoint=0;MFSampleExtension_Interlaced=0
    Line 149834: 552,3F90 13:03:30.53471 CMFTransformDetours::ProcessInput @0000027790451EE0 Stream ID 0, Sample @000002779DB2F500, Time 7300ms, Duration 33ms, Buffers 1, Size 662B, {73A954D4-09E2-4861-BEFC-94BD97C08E6E}=73000000 (0,73000000);MFSampleExtension_Token=@000002779DB1F640;MFSampleExtension_DeviceTimestamp=73000000 (0,73000000);MFSampleExtension_CleanPoint=0;MFSampleExtension_Interlaced=0  

MFTrace events (filtered of “Met=”) MEStreamSinkRequestSample= 305 MEMediaSample= 213

Line 151717: 552,3F90 13:03:30.63479 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F680, 
Line 152202: 552,3F90 13:03:30.63838 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 152377: 552,3F90 13:03:30.66791 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F5C0, 
Line 152862: 552,3F90 13:03:30.67133 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 153037: 552,3F90 13:03:30.70149 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB30280, 
Line 153522: 552,3F90 13:03:30.70538 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 153697: 552,2DD4 13:03:30.73484 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 154182: 552,2DD4 13:03:30.73861 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 154357: 552,3F90 13:03:30.76793 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FD40, 
Line 154842: 552,3F90 13:03:30.77171 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 155017: 552,3CE4 13:03:30.80114 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FC80, 
Line 155502: 552,3CE4 13:03:30.80453 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 155677: 552,3CE4 13:03:30.83483 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FF80, 
Line 156162: 552,3CE4 13:03:30.83832 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 156337: 552,A50 13:03:30.86834 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F500, 
Line 156822: 552,A50 13:03:30.87180 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 156997: 552,3CE4 13:03:30.90157 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FB00, 
Line 157482: 552,3CE4 13:03:30.90504 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 157657: 552,3CE4 13:03:30.93457 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @0000027790460240, 
Line 158142: 552,3CE4 13:03:30.93822 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 158317: 552,3CE4 13:03:30.96831 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F680, 
Line 158802: 552,3CE4 13:03:30.97161 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 158977: 552,2DD4 13:03:31.00100 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F5C0, 
Line 159462: 552,2DD4 13:03:31.00419 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 159637: 552,2DD4 13:03:31.03442 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB30280, 
Line 160122: 552,2DD4 13:03:31.03824 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 160297: 552,2DD4 13:03:31.06790 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 160930: 552,2DD4 13:03:31.07260 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 161105: 552,A50 13:03:31.10179 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 161443: 552,A50 13:03:31.13445 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 161781: 552,A50 13:03:31.16811 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 162119: 552,A50 13:03:31.19194 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 162457: 552,A50 13:03:31.23510 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 162795: 552,A50 13:03:31.26862 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 163133: 552,A50 13:03:31.30162 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 163463: 552,A50 13:03:31.33445 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FD40, 
Line 163781: 552,A50 13:03:31.36811 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB30280, 
Line 164099: 552,A50 13:03:31.40173 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F5C0, 
Line 164417: 552,A50 13:03:31.43510 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F680, 
Line 164735: 552,A50 13:03:31.46827 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @0000027790460240, 
Line 165053: 552,A50 13:03:31.50162 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FB00, 
Line 165371: 552,A50 13:03:31.53487 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F500, 
Line 165689: 552,A50 13:03:31.56838 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FF80, 
Line 166174: 552,A50 13:03:31.57268 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 166349: 552,A50 13:03:31.60165 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FC80, 
Line 166934: 552,A50 13:03:31.60533 CMFStreamSinkDetours::EndGetEvent @000002779045A878 Met=305 (null), value (empty), 
Line 167109: 552,3CE4 13:03:31.63434 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2F980, 
Line 167427: 552,3CE4 13:03:31.66812 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @000002779DB2FB00, 
Line 167745: 552,3CE4 13:03:31.70109 CMFMediaStreamDetours::EndGetEvent @0000027792FF7930 Met=213 (null), value @0000027790460240,

If you think any more data is required, and can direct me at that direction comment the question and I'll add it as fas as I can with an edit title.

标签: videoffmpegrtspms-media-foundation

解决方案


我试图解决这个问题的想法之一是使用 ffmpeg 进行解码,并将未压缩的图像 (I420) 传递给媒体基础。这为我解决了这个问题。由此我得出结论,问题出在 h264 解码器上,它不能很好地处理直播流。


推荐阅读