如何在解码器过滤器中创建时间戳?
感谢 Roman R 对我之前问题的回答,我现在有了一个包含第三方解码器库的异步过滤器。
编码的输入样本来自网络源。目前,我没有向解码帧添加时间戳,因此帧速率相当不稳定,因为它取决于接收数据包的时间。
当库解码完整帧时,它还会根据源编码器上的时钟提供捕获帧的时间的 UTC 时间戳。
问题是:如何将其与流时间联系起来并为 SetTime 函数创建一个合理的值?我已经尝试过它,但我输入的任何值似乎都将过滤器图锁定在 CBaseOutputPin::Deliver 函数中。
Thanks to Roman R's answer to my previous question I now have an asynchronous filter wrapping a 3rd party decoder library.
The encoded input samples are coming from a network source. At present I am not adding timestamps to the decoded frames so the framerate is rather jerky as it is dependent on the time the data packets are received.
When the library decodes a full frame it also provides a UTC timestamp of the time the frame was captured according to the clock on the source encoder.
The question is: how can I related this to the stream time and create a sensible value for the SetTime function? I've played around with it but what ever values I put in just seem to lock up the filter graph at the CBaseOutputPin::Deliver function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的时间戳如下。您可以用零对第一个媒体样本进行时间戳记(请参阅下一段中的调整说明),并且以下内容将被标记为与它不同。也就是说,您开始流式传输并从网络源获取第一个样本,您这次记住
UTC0
并将零附加到 DirectShow 媒体样本。跟随帧 1、2 ... N,使用 UTC 时间UTC1
...UTCN
并将转换为 DirectShow 时间UTCN
-UTC0
。您可能需要额外转换为适当的单位,因为 DirectShow 将需要 100 ns 单位,而您的网络源可能会为您提供类似 1/90000 s 的单位。由于您的源可能是实时源,并且您的第一帧可能不完全在图形运行时获得,因此您可能会使用当前过滤器图形的
IReferenceClock::GetTime
之间的差异来调整生成的媒体样本时间戳以及作为 IBaseFilter::Run 调用参数接收的时间。The easiest time stamping is as follows. You time stamp your first media sample with a zero (see adjustment note in next paragraph) and the following will be stamped with a difference against it. That is, you start streaming and you obtain first sample from your network source, you remember this time
UTC0
and attach zero to the DirectShow media sample. Following frames 1, 2 ... N with UTC timesUTC1
...UTCN
and will be converted to DirectShow timeUTCN
-UTC0
. You might need an additional conversion to proper units, as DirectShow will need 100 ns units and your network source might be giving you something like 1/90000 s.Since your source is perhaps a live source, and your first frame might be obtained not exactly at graph run time, you might be adjusting resulting media sample time stamp using a difference between current filter graph's
IReferenceClock::GetTime
and time received as argument toIBaseFilter::Run
call.