Use Frames from the Multimedia Toolkit with the Rest of LEADTOOLS Without Video Filter Callback

This tutorial shows the most efficient way of creating a BITMAPHANDLE from a frame sample.

The following is an overview of the process:

  1. ltmmConvert and ltmmCapture objects can pass you each sample using the IltmmMediaSampleDisp Interface. For simplicity, we will be using the ltmmConvert object from now on, but similar steps would be used with the ltmmCapture object.

  2. You should create a ltmmMediaType object and set its:

    1. Type to be video (using IltmmMediaTypeDisp::put_type)

    2. Subtype to uncompressed RGB24 or 8-bit (using IltmmMediaTypeDisp::put_subtype) because this is the only type of data LEADTOOLS can use

  3. Call IltmmSampleTarget::SetAcceptedMediaType to set the output sample type. You can also free the ltmmMediaType object since it is not needed anymore.

  4. Specify that the output from ltmmConvert object will be the target sample grabber by calling IltmmConvert::put_TargetObject.

  5. Make the convert object create its graph to know the size of the output samples. You can call IltmmConvert::put_SourceFile to tell it to start converting from an AVI file. Call IltmmConvert::StartConvert to force the filter to build the filter graph and update the output type.

  6. Get the ltmmMediaType object which will be used by the sample grabber object by calling IltmmSampleTarget::GetConnectedMediaType. Get the dimensions of the samples by calling IltmmMediaTypeDisp::get_Format.

  7. Use the width and height from the media type and create the shell LEADTOOLS bitmap by calling L_CreateBitmap and passing TYPE_USER for uMemory parameter. You can pass NULL for data if you do not have the data yet.

  8. For each sample:

    1. Retrieve a sample using IltmmSampleTarget::GetSample.
    2. Call IltmmMediaSampleDisp::get_Buffer to get direct access to the sample data
    3. Call L_SetBitmapDataPointer to set the LEADTOOLS bitmap data pointer to the sample data.
    4. Use the LEAD bitmap.
    5. Release the sample by calling IltmmSampleTarget::Release.

    Note

    The shell bitmap should not be used after calling IltmmSampleTarget::Release. You should only call L_FreeBitmap or L_SetBitmapDataPointer beyond this point.

  9. Stop the conversion by calling IltmmConvert::StopConvert and free any memory (other than the bitmap data) allocated for the shell bitmap using L_FreeBitmap.

Example

For a C example, refer to Splitting an AVI File into a Multipage TIFF File Using ltmmSampleTarget for C.

For a C++ example, refer to Splitting an AVI File into a Multipage TIFF File Using ltmmSampleTarget for C++.

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help

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