On Nov 18, 3:17 pm, Jerislav <jeris...[ at ]gmail.com> wrote:
[Quoted Text]
Hi,
Thanks for the reply. I have created a simple application to write video image samples according to the Windows Media Format 11 documentation ( http://msdn.microsoft.com/en-us/library/aa392242 (VS.85).aspx ). But when adding a stream to the profile object ( ppProfile->AddStream( pIStreamConfig ) ) the return value of HRESULT is -1072889796. And also when setting the profile to the writer object ( pWriter->SetProfile(ppProfile) ), the return value of HRESULT is -1072886842. The source code of the program is attached with this.(I have noted the error values as comments on the source code). Can any one help me to identify the problem here?
Thanks & Regards,
Kelum
///////////////////////////////////////////////////////////////// // source code ////////////////////////////////////////////////////////////////
#include "stdafx.h" #include <wmsdk.h>
int _tmain(int argc, _TCHAR* argv[]) {
HRESULT hr = S_OK; IWMProfile * ppProfile; IWMProfileManager * pProfileMgr; IWMCodecInfo3 * pCodecInfo; IWMStreamConfig * pIStreamConfig; IWMStreamConfig * pIWMStreamConfig2 = NULL; IWMMediaProps * pImediaprops; IWMMediaProps * pIWMMediaProps2 = NULL; WM_MEDIA_TYPE * pMediaType; IWMWriter *pWriter = NULL; DWORD pcbType; DWORD cCodecs = 0; DWORD cFormats; DWORD cStreams = 0; DWORD cInputs = 0; WCHAR* pwszCodecName = NULL; DWORD cchCodecName = 0; DWORD dwCodecIndex; WORD wStreamNum = 0; DWORD dwBitrate = 1024;
hr = CoInitialize( NULL );
hr = WMCreateProfileManager(&pProfileMgr); // Create the empty profile. hr = pProfileMgr->CreateEmptyProfile(WMT_VER_8_0, &ppProfile);
hr = pProfileMgr->QueryInterface( IID_IWMCodecInfo3, ( void ** ) &pCodecInfo );
hr = pCodecInfo->GetCodecInfoCount(WMMEDIATYPE_Video, &cCodecs);
// Loop through the video codecs. for(dwCodecIndex = 0; dwCodecIndex < cCodecs; dwCodecIndex++) { hr = pCodecInfo->GetCodecFormatCount( WMMEDIATYPE_Video, dwCodecIndex, &cFormats );
pCodecInfo->GetCodecFormat(WMMEDIATYPE_Video,dwCodecIndex,0, &pIStreamConfig); hr = pIStreamConfig->QueryInterface(IID_IWMMediaProps, (void **) &pImediaprops ); hr = pImediaprops->GetMediaType(0x00, &pcbType); pMediaType = (WM_MEDIA_TYPE*) new BYTE[pcbType]; hr = pImediaprops->GetMediaType(pMediaType, &pcbType);
if(pMediaType->subtype == WMMEDIASUBTYPE_WMVP) { hr = ppProfile->CreateNewStream( pMediaType->subtype, &pIWMStreamConfig2 ); hr = pIWMStreamConfig2->GetStreamNumber( &wStreamNum ); hr = pIStreamConfig->SetStreamNumber( wStreamNum ); hr = pIStreamConfig->SetStreamName( L"Video Stream" ); hr = pIStreamConfig->SetConnectionName( L"Video" ); hr = pIStreamConfig->SetBitrate( dwBitrate ); hr = pIStreamConfig->QueryInterface( IID_IWMMediaProps, (void **) &pIWMMediaProps2 ); hr = pIWMMediaProps2->SetMediaType(pMediaType );
hr = ppProfile->AddStream( pIStreamConfig ); // hr = -1072889796
hr = WMCreateWriter(NULL, &pWriter);
hr = pWriter->SetProfile(ppProfile); // hr = -1072886842
hr = pWriter->GetInputCount( &cInputs );
// rest of the programm // //
} delete[] pMediaType;
}
CoUninitialize(); return 0; }
|