none
WMV9 Encoding;4CC WMV3;Profile

    Question

  • Hi to all,

     

    I have an uncopressed avi file and I would like to convert it in a .wmv with WMV3 codec, Window Media Video 9.

    I'm using WM ASF Writer creating a new Profile but when I call AddStream it always return NS_E_INVALID_STREAM

    if I SetBitrate > 0, some body can help me to understand way ?

    I'm using WM ASF Writer creating a new Profile for Window Media Video 9 in this way:

     

    // BEGIN CODE

    // I removerd check errors lines for to compact the source code.

    DWORD dwBitRate = 1000;

    DWORD dwQuality = 50; // in range[0-100]

    DWORD dwSecPerKey = 5000;

     

    IWMProfileManager* pIPM = 0;

    WMCreateProfileManager(&pIPM);

     

    IWMProfile* pIProf = 0;

    pIPM->CreateEmptyProfile(WMT_VER_9_0,&pIProf);

     

    pIProf->SetName(L"Window Media Video 9 Profile");

    pIProf->SetDescription (L"Window Media Video 9 Custom Encoding");

     

    IWMStreamConfig* pVideoStream = 0;

    pIProf->CreateNewStream(WMMEDIATYPE_Video,&pVideoStream);

     

    pVideoStream->SetConnectionName (L"Video Input 01");

    pVideoStream->SetStreamName (L"Video Stream 01");

    pVideoStream->SetStreamNumber (1);

    pVideoStream->SetBufferWindow (0xFFFFFFFF);

    pVideoStream->SetBitrate (dwBitRate); // if I skip this line, AddStream will return S_OK. why ?

     

    IWMVideoMediaProps* pVideoMediaProps = 0;

    // Get this Interface from pVideoStream...

     

    pVideoMediaProps->SetQuality (dwQuality);

    pVideoMediaProps->SetMaxKeyFrameSpacing (10000000 * (QWORD)dwSecPerKey );

     

     

    WM_MEDIA_TYPE wm_mt;

    WMVIDEOINFOHEADER videoInfo;

    ::ZeroMemory(&wm_mt,sizeof(wm_mt));

    ::ZeroMemory(&videoInfo,sizeof(WMVIDEOINFOHEADER));

    videoInfo.rcSource.left = 0;

    videoInfo.rcSource.top = 0;

    videoInfo.rcSource.right = 400;

    videoInfo.rcSource.bottom = 400;

    videoInfo.rcTarget = videoInfo.rcSource;

    videoInfo.dwBitRate = dwBitRate;

    videoInfo.AvgTimePerFrame = 400000;

    videoInfo.bmiHeader.biCompression = MAKEFOURCC(_T('W'),_T('M'),_T('V'),_T('3'));

    videoInfo.bmiHeader.biWidth = 400;

    videoInfo.bmiHeader.biHeight = 400;

     

    wm_mt.majortype = WMMEDIATYPE_Video;

    wm_mt.pbFormat = (BYTE*)&videoInfo;

     

    pVideoMediaProps->SetMediaType(&wm_mt);

     

    hr = pIProf->AddStream(pVideoStream);

    if (hr == NS_E_INVALID_STREAM){

    // Here the problem!

    }

    // END CODE

     

    Thanks very much.

     

    Andrew

     

     

    Thursday, January 10, 2008 10:48 AM

Answers

All replies