在 DirectShow 中查找样本采集器何时准备就绪
我正在继续开发 DirectShow 应用程序,并且正在对其进行最后的修饰。该程序正在做的是以 1 秒的时间间隔浏览视频文件,并从采样采集器捕获当前缓冲区并在继续之前对其进行处理。然而,我注意到我在测试中得到了重复的图像,我发现 DirectShow 没有以足够快的速度在 1 秒间隔内通过视频递增。我的问题是是否有一种方法可以检查 DirectShow 何时准备好让我调用 Samplegrabber 来获取当前帧并处理它。目前我调用 sleep 1 秒,但必须有更好的方法。预先感谢您的帮助。
编辑
我只是尝试运行检查以查看视频的位置是否等于我想要抓取和处理的下一个位置。这减少了重复帧的数量,但我仍然看到它们以块的形式出现。
I am continuing work on my DirectShow application and am just putting the finishing touches on it. What the program is doing is going through a video file in 1 second intervals and capturing from the samplegrabber the current buffer and processing it before moving on. However, I was noticing that I was getting duplicate images in my tests to which I found out that DirectShow has not incremented through the video in that 1 second interval fast enough. My question is if there is a way to check when DirectShow is ready for me to call the samplegrabber to get the current frame and to process it. At the moment I call sleep for 1 second but there has to be a better method. Thank you in advance for the help.
EDIT
I just tried running a check to see if the video's position is equal to the next position that I would like to grab and process. That decreased the number of duplicate frames but I still see them showing up in chunks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我总是让 DS 框架来处理处理速率:
在主应用程序线程中,配置样本采集器回调,然后当回调被触发时,您将获得媒体样本以及样本时间:此时,如果经过了适当的间隔(即 1 秒),您就可以处理样本。
你所说的睡眠是什么意思,你从哪里(哪个线程)调用它?
如果您从回调内部执行此操作,您实际上会阻塞 DirectShow 管道吗?也许如果您能更详细地解释您的设置,我可能会更有帮助。
PS如果你想尽快处理样本,你可以在回调中将样本时间戳设置为NULL。
I always let the DS framework handle the processing rate:
in the main application thread, configure the sample grabber callback and then when the callback is triggered, you get the media sample as well as sample time: at this point you can process the sample if the appropriate interval i.e. 1 second has elapsed.
What do you mean you call sleep for a second and from where (which thread) do you call it?
If you're doing this from inside the callback you are effectively blocking the DirectShow pipeline? Perhaps if you could explain your setup in more detail I could be more helpful.
P.S if you want to process the samples as fast as possible, you can set the sample timestamp to NULL in your callback.
尝试将图形计时器设置为 NULL。它将允许:
当然,如果您同时将文件渲染到屏幕上,则它将不起作用。
Try setting your graph timer to NULL. It will allow to:
Of course, it won't work if you are rendering the file to screen at the same time.