How can I add a preview stream to the graph without stopping it?

╄→гoц情女王★ 提交于 2019-12-01 11:37:03

问题


The problem is to build a capture graph supported three states:

  1. Preview only
  2. Capture to AVI-file only
  3. Combine

I have built the graph like this:

This graph corresponds to state 3. Now, if I want to change on state 2 I remove the preview stream and get the graph like this:

Imagine I run the graph and start capture. Now I want to back to state 3. How can I do this (add a preview stream) without stopping the graph? (Capture should continue).

UPD. Maybe it will be possible to capture to the end of AVI-file? If so, I could stop the graph at state 2, add a preview stream to it (change to state 3) and continue capture to the end of exsisting AVI-file (generated on previous step). Is it possible?

UPD2. I found some hack. When I want to change on state 2 from state 3 I just hide a preview-window. When I want to back to state 3 I show a preview-window. Thus, I don't need state 2 anymore since state 2 is just state 3 with hided preview-window!


回答1:


Even though Dynamic Graph Building exists (see also Dynamic Reconnection), in most cases it is of little use:

In most DirectShow filters, pins cannot be reconnected while the graph is actively streaming data. The application must stop the graph before reconnecting the pins. However, some filters do support pin reconnections while the graph is running, a process known as dynamic reconnection.

Most likely the filters you are using would be incompatible with dynamic reconnection, or limiting extensibility. You might have other reasons to not use this approach, e.g. if you cannot afford delays and dropped data while dynamic operation is in progress.

The typical solution involves two graphs: live (capture, preview presentation) and recording. You pass data between the two to make the work in sync. You might want to read up of graph bridging and GMFBridge.

There are quite a few questions on this topic you might want to read as well:

  • Directshow Preview Only and Capture & Preview with a single Graph
  • DirectShow capturing to multiple files
  • change recording file programmatically in directshow


来源:https://stackoverflow.com/questions/22069432/how-can-i-add-a-preview-stream-to-the-graph-without-stopping-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!