Display the video collected by DirectShow in any window.

xiaoxiao2021-03-05  22

After building the ICApturegraphBuilder chart with DirectShow, you can collect the video correctly. However, in general, the video is displayed in a dialog box that is displayed in a system automatically, which describes how to display the captured video in any window.

Here is an example of display to a cstatic (ie, a rectangle). (Application IvideoWindow Interface)

After building the Video Capture Filter Graph, we only need to call iMediaControl :: Run () to start the video preview. We only need to add the following two functions in front of RUN to achieve the function of previewing the video in the STATIC.

Bool setuPvideoWindow () {

HRESULT HR;

HR = PVW-> Put_owner (m_nvideoWindow.m_hwnd); // m_nvideoWindow (CSTATIC Object)

IF (Failed (HR)) Return False;

// set video window style hr = pvw-> put_windowstyle (WS_CHILD | WS_CLIPCHILDREN); // PVW (IvideoWindow Interface) IF (Failed (HR)) Return False;

HR = PVW-> PUT_Visible (OATRUE); IF (Failed (HR)) Return False;

Return True;}

Void ResizeVideoWindow () {if (pvw) {Rect rc; // make the preview video function company window m_nvideowindow.getClientRect (& rc); pvw-> setWindowPosition (0, 0, rc.right, rc.bottom);}}

转载请注明原文地址:https://www.9cbs.com/read-37852.html

New Post(0)