I have a Directshow application that needs to preview a webcam video, and when user clicks 'Record' it needs to start capturing the video to a file.
To that end I created a single Capture Graph, with PREVIEW pin connected to a RENDER filter and CAPTURE pin connected to a AVI_MUX filter that saves to a file.
It looks something like this:
/[PREVIEW PIN]-->[VIDEO_RENDERER]--->[SCREEN]
[VIDEO CAPTURE FILTER] /
[CAPTURE PIN]--->[AVI_MUX]--->[FILE WRITER]
When I call Run() on the graph the video shows on screen and gets saved to the file correctly.
My question is, how can I only run the PREVIEW PIN section of the graph without the CAPTURE_PIN section.
My initial idea was to manually start/stop respective filters, but then I looked at Microsoft's Directshow amcap sample, and they actually create two separate graphs. One for preview and one for capture. If the user wants to preview video, they destroy capture graph and create preview graph. And if the user wants to record video, they destroy preview graph and create capture graph.
That seems kind of wasteful, especially since a single graph already contains both PREVIEW and CAPTURE pins. What is the right approach here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…