SinkWriter(或等效的)的多线程使用 [英] Multi-threaded use of SinkWriter (or equivalent)

查看:72
本文介绍了SinkWriter(或等效的)的多线程使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将生成的位图保存到视频文件中。我有IMFSinkWiter工作得很好,但我只使用两个线程(一个用于生成帧,第二个用于通过IMFSinkWriter将它们写入文件。有没有办法为输出使用多个
线程如果机器有一个多核CPU,那么添加更多线程进行帧生成不是我的问题 - 最慢的操作是将它们写入输出文件。从我的实验中,IMFMediaSink不处理
将输出框架添加到输出中的情况除了它们呈现给API的顺序之外.API工作,但视频文件是无序编写的。

I would like to save generated bitmaps to a video file. I have IMFSinkWiter working perfectly well, but I am only using two threads (one to generate the frames, and the second to write them to the file via IMFSinkWriter. Is there a way to use more than one thread for the output to the video file if the machine has a multi-core CPU? Adding more threads for frame generation is not my problem - the slowest operation is writing them to the output file.  From my experiments IMFMediaSink does not deal with the case of adding frames to the output in anything other than the sequence they are presented to the API. The API works, but the video file is written out of order.

因此,对于使用一个线程进行输出的简单情况,IMFSinkWiter非常适用,我是否应该使用另一个媒体基础组件来批量处理帧或者以某种方式对它们进行交错?或者如果你写的话IMFSinkWiter工作得非常好
来自多个线程的帧无序,我还有其他一些跟踪追踪?

So IMFSinkWiter works perfectly well for the simple case of using one thread for output, should I use another media foundation component to process frames for output in batches or interleve them somehow? Or should IMFSinkWiter  work perfectly well if you write the frames out of order from multiple threads & I have some other issue to track down?

推荐答案

Media Foundation可以使用异步调用,这与多线程类似。有一个工作队列将帮助您完成线程同步。

Media Foundation can use asynchronous calls, which is the similar with Multi-threaded. There is a work queues will help you to do the threads synchronization.

您不需要更多代码来控制它。

http://msdn.microsoft.com/en-us/library/windows/desktop/ms705623(v = vs.85)。 aspx

You don't need more codes to control this.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms705623(v=vs.85).aspx

最好的问候,

Jesse

Best regards,
Jesse


这篇关于SinkWriter(或等效的)的多线程使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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