Quantcast
Channel: Media Foundation Development for Windows Desktop forum
Viewing all articles
Browse latest Browse all 1079

resize video

$
0
0

Hi,

could you tell me the best approach to resize a video (Win7 & Win8)? At the moment I am trying to use the video resizer DSP, but the video is not always resized correctly. Sometimes I get only some strange pixel-images. Sometimes it works. 

        hr = CoCreateInstance (CLSID_CResizerDMO, NULL, CLSCTX_ALL, __uuidof(IMFTransform), (void**)(&rescaler));
        IPropertyStore* thePropertyStore;
        hr = rescaler->QueryInterface (&thePropertyStore);

        PROPVARIANT theWidthVariant, theHeightVariant;
        InitPropVariantFromInt32 (videoOutputWidth, &theWidthVariant);
        InitPropVariantFromInt32 (videoOutputHeight, &theHeightVariant);
        thePropertyStore->SetValue (MFPKEY_RESIZE_MINAPWIDTH, theWidthVariant);
        thePropertyStore->SetValue (MFPKEY_RESIZE_MINAPHEIGHT, theHeightVariant);

        PROPVARIANT theXVariant, theYVariant;
        InitPropVariantFromInt32 (0, &theXVariant);
        InitPropVariantFromInt32 (0, &theYVariant);
        thePropertyStore->SetValue (MFPKEY_RESIZE_MINAPX, theXVariant);
        thePropertyStore->SetValue (MFPKEY_RESIZE_MINAPY, theYVariant);

Which additional properties do I have to set? "videoOutputWidth" and "videoOutputHeight" should be the size of the resized video. Depending on the used properties, ProcessOutput returns E_FAIL (for example, if I try to set MFPKEY_RESIZE_DST_WIDTH with videoOutputWidth.

        IMFMediaType* inputType;
        IMFMediaType* outputType;

        hr = decoder->GetOutputCurrentType (0, &inputType);   //from the decoder IMFTransform
        MFCreateMediaType (&outputType);

        inputType->CopyAllItems (outputType)

        MFSetAttributeSize (outputType, MF_MT_FRAME_SIZE, videoOutputWidth, videoOutputHeight);

        hr = rescaler->SetInputType (0, inputType, 0);
        hr = rescaler->SetOutputType (0, outputType, 0);
        hr = rescaler->ProcessInput (0, sample, 0);

        hr = rescaler->ProcessOutput(0, 1, &outputbuffer, &status);

best regards

saoirse


Viewing all articles
Browse latest Browse all 1079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>