如何获得40ms的间隔? [英] How to get 40ms intervals?

查看:63
本文介绍了如何获得40ms的间隔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是DirectShow编程的新手.我需要从yuv视频文件中准确提取每帧40ms的时间,以将其推送到源过滤器.
我使用了睡眠功能,但它没有给出40ms的间隔.

请建议我,还有其他方法可以满足计时要求吗?我使用的操作系统是Windows XP.

Hi,

I am new to directshow programming. I need to extract each frame exactly at 40ms from a yuv video file to give it a push to source filter.
I used Sleep function, but it does not give 40ms intervals.

Please suggest me, is there any other methods to meet the requirement of timing? I am using OS windows XP.

推荐答案

如果需要精确的计时器间隔,则不能使用任何版本的Windows来运行代码. Windows不是实时操作系统.
您可以使用计时器队列API [计时器教程 [
If you need exact timer intervals, then you can''t use any version of Windows to run your code. Windows isn''t a real-time operating system.
You can use the Timer Queue API[^] for creating events at millisecond resolution, but the execution of your code after the event is subject to scheduling delays. The only guarantee you get is that the interval between code executions is at least the specified period. See also: Timers Tutorial[^]


我不知道这是多么可行,但是如何设置两个(甚至三个)全都设置为120ms的线程,并对所有线程执行级联启动

启动第一个线程,并在第一个帧捕获上启动第二个线程,后者将启动第三个线程.这样,您可以捕获每三帧,而不必担心时间问题.
I don''t know how viable this is, but how about setting up two (or even three) threads that are all set for 120ms, and perform a cascading start on all of them

Start the first thread, and on the first frame capture, start the second thread, which would start the third. That way, you can capture every third frame and not have to worry as much about timing.


这篇关于如何获得40ms的间隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆