In This Topic ▼

Use ltmfCapture to Perform a Capture and Save It as a WMV File

  1. Create an instance of the ltmfCapture class. This is accomplished using the Win32 CoCreateInstance function, as follows:

    C
    IltmfCapture* pCapture; 
    CoCreateInstance(&CLSID_ltmfCapture, NULL, CLSCTX_INPROC_SERVER,&IID_IltmfCapture,(void**) &pCapture); 
    C++
    IltmfCapture* pCapture; 
    CoCreateInstance(&CLSID_ltmfCapture, NULL, CLSCTX_INPROC_SERVER,&IID_IltmfCapture, (void**) &pCapture); 

  2. Define the notification window, which receives the capture status notifications:

    C
    HWND hwndNotify; 
    #define WM_CAPTURENOTIFY (WM_USER + 1000) 
    IltmfCapture_SetNotifyWindow(pCapture, (long)hwndNotify, WM_CAPTURENOTIFY); 
    C++
    HWND hwndNotify; 
    #define WM_CAPTURENOTIFY (WM_USER + 1000)  
    pCapture->SetNotifyWindow((long)hwndNotify, WM_CAPTURENOTIFY); 
    The above code instructs the capture object to send WM_CAPTURENOTIFY messages to the window procedure of hwndNotify. The wParam parameter of the window message will contain the notification code.

    ✎ NOTE

    A capture can be accomplished without using a notification window, but the user would be required to poll the objects state to determine when the capture has finished.

  3. Define a frame window for the video preview:

    C
    HWND  hwndFrame; 
    IltmfCapture_put_VideoWindowFrame(pCapture, (long)hwndFrame); 
    C++
    HWND hwndFrame; 
    pCapture->put_VideoWindowFrame((long)hwndFrame); 

    The user is required to create the window that serves as the video frame. ltmfCapture will subclass this window, so there is no need to forward any messages to the ltmfCapture object. By default, ltmfCapture will automatically maximize the video within the frame window. The video will automatically resize when the frame window size changes.

    ✎ NOTE

    The notification window and the video frame window can be the same.

  4. Set the Target file:

    C
    BSTR bstr; 
    bstr = SysAllocString(L"c:\\captured.wmv"); 
    IltmfCapture_put_Target 
    C++
    BSTR bstr; 
    ::SysAllocString(L"c:\\captured.wmv"); 
    pCapture->put_TargetFile(bstr); 
    ::SysFreeString(bstr); 

  5. Set the video device:

    C
    IltmfDevices* devices; 
    IltmfCapture_get_VideoDevices(pCapture, &devices); 
    IltmfDevices_put_Selection(devices, 0); 
    IltmfDevices_Release(devices); 
    C++
    IltmfDevices* devices; 
    pCapture->get_VideoDevices(&devices); 
    devices->put_Selection(0); 
    devices->Release(); 

  6. Set the audio device:

    C
    HIltmfDevices* devices; 
    IltmfCapture_get_AudioDevices(pCapture, &devices); 
    IltmfDevices_put_Selection(devices, 0); 
    IltmfDevices_Release(devices); 
    C++
    IltmfDevices* devices; 
    pCapture->get_AudioDevices(&devices); 
    devices->put_Selection(0); 
    devices->Release(); 

  7. Set the target format :

    C
    IltmfCapture_put_TargetFormat(pCapture, ltmfCapture_TargetFormat_WMV); 
    C++
    pCapture->put_TargetFormat(ltmfCapture_TargetFormat_WMV); 

  8. To start capturing, call the StartCapture function as follows:

    C
    IltmfCapture_StartCapture(pCapture, ltmfCapture_Mode_VideoAndAudio) 
    C++
    pCapture->StartCapture(ltmfCapture_Mode_VideoAndAudio); 

  9. To stop capturing, call the StopCapture function as follows:

    C
    IltmfCapture_StopCapture(pCapture); 
    C++
    pCapture->StopCapture(); 

  10. Release the capture object (and all active objects) when you are done.

Target format

The format to be used for the converted file. This includes the file format, any special settings used by that format, and which audio and/or video codec is to be used for the conversion, and any special settings used by the codecs.

Codec

A COmpressor combined with a DECompressor, or encoder and a decoder, which allows you to both compress and decompress that same data.
Help Version 22.0.2022.6.24
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Media Foundation C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.