Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Varun_R_2
Beginner
92 Views

Unable to init MFXVideoENCODE

Hi All,

I tried to write a sample encoder code and provided all the mandatory parameters (As per Appendix A: Configuration Parameter Constraints Encode, SDK API Page Num: 200) to in the mfxVideoParam structure.

When i tried to run the application, getting seg fault.

Following is the code:

#include"mfxaudio++.h"
#include"mfxvideo++.h"
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "mfxplugin.h"
#include "mfxstructures.h"
#include "mfxdefs.h"
#include "common_utils.h"

int main(int argc, char* argv[])
{
        mfxSession session;
        MFXVideoENCODE enc(session);

        mfxStatus sts;
        mfxVideoParam in, out;
        mfxIMPL impl=MFX_IMPL_HARDWARE_ANY;
        mfxVersion version;
        version.Major=1;
        version.Minor=0;

        mfxVideoParam Params_in, Params_out;
        int size=sizeof(Params_in);
        memset(&Params_in,0,sizeof(Params_in));

        Params_in.IOPattern=MFX_IOPATTERN_IN_SYSTEM_MEMORY;

        Params_in.mfx.CodecId=MFX_CODEC_AVC;
        Params_in.mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED;
        Params_in.mfx.TargetKbps = 4000;
        Params_in.mfx.EncodedOrder = 0;
        Params_in.mfx.RateControlMethod = MFX_RATECONTROL_VBR;

        Params_in.mfx.FrameInfo.FourCC = MFX_FOURCC_NV12;
        Params_in.mfx.FrameInfo.FrameRateExtN = 30;
        Params_in.mfx.FrameInfo.FrameRateExtD = 1;
        Params_in.mfx.FrameInfo.CropX = 0;
        Params_in.mfx.FrameInfo.CropY = 0;
        Params_in.mfx.FrameInfo.CropW = 0;
        Params_in.mfx.FrameInfo.CropH = 0;
        Params_in.mfx.FrameInfo.Width = 1000;
        Params_in.mfx.FrameInfo.Height = 1000;
        Params_in.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
        sts = enc.Init(&Params_in);
        if (MFX_ERR_NONE != sts)
        {
                printf("%s: Function:%s: Line #%d Failed\n", __FILE__, __FUNCTION__, __LINE__);
                exit(0);
        }
        else
                printf("Success\n");

}

In sample application, not finding any example which is directly initializing the parameters. Please let me know, is there any specific example where i can find all the required initialization code for encoder and decoder?

Thanks.

0 Kudos
2 Replies
Surbhi_M_Intel
Employee
92 Views

Hi Varun, 

For a simple code samples to start with, look at the tutorials package which provide basic, easy approach to learn basic media features and how to build applications using media sdk, has very clear detailed pipeline set for the encoder/decoder application. For details on understanding the framework of MSDK pipeline, check this blog -https://software.intel.com/en-us/articles/framework-for-developing-applications-using-media-sdk. Let us know if you have any further questions. 

Thanks,
Surbhi
 

Varun_R_2
Beginner
92 Views

Hi Surbhi,

Thanks for sharing the blog details to understand MSDK.

Will go thru it.

Reply