简体   繁体   English

Media Foundation H264解码器无法正常工作

[英]media foundation H264 decoder not working properly

I'm creating an application for video conferencing using media foundation and I'm having an issue decoding the H264 video frames I receive over the network. 我正在创建一个使用Media Foundation的视频会议应用程序,但在解码通过网络接收到的H264视频帧时遇到问题。

The Design 该设计

Currently my network source queues a token on every request sample, unless there is an available stored sample. 当前,除非有可用的存储样本,否则我的网络源会在每个请求样本上将令牌排队。 If a sample arrives over the network and no token is available the sample is stored in a linked list. 如果样本通过网络到达并且没有令牌可用,则样本将存储在链接列表中。 Otherwise it is queued with the MEMediaSample event. 否则,它将与MEMediaSample事件一起排队。 I also have the decoder set to low latency. 我也将解码器设置为低延迟。

My Issue 我的问题

When running the topology using my network source I immediately see the first frame rendered to the screen. 使用网络源运行拓扑时,我立即看到渲染到屏幕的第一帧。 I then experience a long pause until a live stream begins to play perfectly. 然后,我会经历一段长时间的停顿,直到直播开始完美播放为止。 After a few seconds the stream appears to pause but then you notice that it's just looping through the same frame over and over again adding in a live frame every couple of seconds that then disappears immediately and goes back to displaying the old loop. 几秒钟后,流似乎暂停了,但随后您注意到它只是一次又一次地循环遍历同一帧,每隔几秒钟添加一个实时帧,然后立即消失并返回到显示旧循环。

Why is this happening? 为什么会这样呢? I'm by no means an expert in H264 or media foundation for that matter but, I've been trying to fix this issue for weeks with no success. 对于这件事,我绝不是H264或媒体基金会的专家,但是,我一直试图解决该问题已有数周之久,但没有成功。 I have no idea where the problem might be. 我不知道问题可能在哪里。 Please help me! 请帮我!

The time stamp is created by starting at 0 and adding the duration to it for every new sample. 通过从0开始并为每个新样本添加持续时间来创建时间戳。 The other data is retrieved from a IMFSampleGrabberSinkCallback. 其他数据从IMFSampleGrabberSinkCallback检索。

I've also posted some of my MFTrace onto the msdn media foundation forums Link 我还张贴了一些我MFTrace的到MSDN媒体基金会论坛链接

I mentioned on there that the presentation clock doesn't seem to change on the trace but, I'm unsure if that's the cause or how to fix it. 我在那儿提到演示时钟似乎并没有改变,但是我不确定这是原因还是解决方法。

EDIT : Could you share the video and a full mftrace log for this issue? 编辑 :您是否可以共享视频和完整的mftrace日志以解决此问题? It's not clear for me what really happens: do you see the live video after a while? 我不清楚发生了什么实际情况:一段时间后您是否看到了实时视频?

The current log does not contain enough information to trace sample processing. 当前日志没有足够的信息来跟踪样本处理。 From your description is looks like that only keyframes are rendered. 根据您的描述,看起来只有关键帧被渲染。 Plus, duration is weird for the rendered keyframe: 另外,渲染关键帧的持续时间很奇怪:

    Sample @00A74970, Time 6733ms, Duration 499ms. <- Duration is not 33ms.

I would like to see what happened to that sample. 我想看看那个样品发生了什么。

In any case, if you are using standard encoder and decoder, the issue should be with your media source, and how it buffers frames. 无论如何,如果您使用标准的编码器和解码器,则问题应该出在您的媒体源及其缓冲帧的方式上。 Incorrect circular buffer implementation? 错误的循环缓冲区实现? You may want to try and cache a second or two of samples before starting giving them to the decoder. 在开始将它们提供给解码器之前,您可能需要尝试缓存一两个样本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM