|
|
Hi everyone,
I am trying an assignment to make a video from bmp files. I gone through the help of windows format SDK(new to this). But i didnt find the reason for the error of following code.
hr = pWriter->SetProfileByID( WMProfile_V70_768Video);
This line of code is not giving any kind of compiler error. But while debugging i am getting the following error in debug messages(output box).
First-chance exception in test.exe (WMVCORE.DLL): 0xC0000005: Access Violation.
And ya WMVCORE.DLL is registered
After this every method called by pWriter is giving same access violation error and atlast it is failed to execute EndWriting method.
If anyone find the solution for this problem please write down here.
Thanx Vishy
|
|
From: "vishy"
[Quoted Text] > hr = pWriter->SetProfileByID( WMProfile_V70_768Video); > First-chance exception in test.exe (WMVCORE.DLL): > 0xC0000005: Access Violation.
What's address of the access violation? How are you initializing pWriter?
> And ya WMVCORE.DLL is registered
???
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
On Apr 25, 5:55 pm, "Alessandro Angeli" <nob...[ at ]nowhere.in.the.net> wrote:
[Quoted Text] > From: "vishy" > > > hr = pWriter->SetProfileByID( WMProfile_V70_768Video); > > First-chance exception in test.exe (WMVCORE.DLL): > > 0xC0000005: Access Violation. > > What's address of the access violation? How are you > initializing pWriter?
I think the address is 0xC0000005 this only. But while i debug, when i execute below code
hr = pWriter->SetProfileByID( WMProfile_V70_768Video);
I get the below messages in output box.
Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common- Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found. First-chance exception in test.exe (WMVCORE.DLL): 0xC0000005: Access Violation.
And ya about pWriter, after creating the object i am setting the profile by calling the above line.
|
|
From: "vishy"
[Quoted Text] > I think the address is 0xC0000005 this only. But while i
That's the exception code (which means access violation) and not the memory address the violation occurred at.
> Loaded 'C:\WINDOWS\system32\shlwapi.dll', no matching > symbolic information found.
Ignore this, it is just telling you you don't have a PDB file for this module (you can set up access to the public symbol server on microsoft.com in VisualStudio if you want the stack trace to contain symbolic info in the debug window).
> First-chance exception in test.exe (WMVCORE.DLL): > 0xC0000005: Access Violation.
Since you are running the code in the debugger, you can look at the current value of pWriter when you break and at the stack trace to know where the exception occurred.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
[Quoted Text] > > > I think the address is 0xC0000005 this only. But while i > > That's the exception code (which means access violation) and > not the memory address the violation occurred at.
I didnt know about this, because i am new to this.
And as you asked the current value of pWriter is 0x00328de0 (got from the variables window). And the in stack trace (Call Stack) the following content is there,
main() line 188 mainCRTStartup() line 206 + 25 bytes KERNEL32! 7c816d4f()
I dont know how it can help you to solve my problem.
Thank you Vishy
|
|
On Apr 27, 9:57 am, vishy <vishwanath.kine...[ at ]gmail.com> wrote:
[Quoted Text] > > > I think the address is 0xC0000005 this only. But while i > > > That's the exception code (which means access violation) and > > not the memory address the violation occurred at. > > I didnt know about this, because i am new to this. > > And as you asked the current value of pWriter is 0x00328de0 (got from > the variables window). And the in stack trace > (Call Stack) the following content is there, > > main() line 188 > mainCRTStartup() line 206 + 25 bytes > KERNEL32! 7c816d4f() > > I dont know how it can help you to solve my problem. > > Thank you > Vishy
And for your reference i have posted another topic named bmp to wmv topic where i copied the code. The link is http://groups.google.co.in/group/microsoft.public.windowsmedia.sdk/browse_thread/thread/bc6187a877731586/#
Thank you Vishy
|
|
On Apr 27, 10:21 am, vishy <vishwanath.kine...[ at ]gmail.com> wrote:
[Quoted Text] > On Apr 27, 9:57 am, vishy <vishwanath.kine...[ at ]gmail.com> wrote: > > > > > > > > > I think the address is 0xC0000005 this only. But while i > > > > That's the exception code (which means access violation) and > > > not the memory address the violation occurred at. > > > I didnt know about this, because i am new to this. > > > And as you asked the current value of pWriter is 0x00328de0 (got from > > the variables window). And the in stack trace > > (Call Stack) the following content is there, > > > main() line 188 > > mainCRTStartup() line 206 + 25 bytes > > KERNEL32! 7c816d4f() > > > I dont know how it can help you to solve my problem. > > > Thank you > > Vishy > > And for your reference i have posted another topic named bmp to wmv > topic where i copied the code. > The link is http://groups.google.co.in/group/microsoft.public.windowsmedia.sdk/br...> > Thank you > Vishy- Hide quoted text - > > - Show quoted text -
Or else try this code, the same code from above but i put it all in one main( ). In this WriteSample is returning NS_E_NOT_CONFIGURED.
int main(void) { HRESULT hr = NULL; char *szInputFile = "D:\\BitmapSet1.bmp"; unsigned short *szOutFile = L"D:\\vishy.wmv"; HANDLE hFile;
hr = CoInitialize(NULL);
hFile = (HANDLE)CreateFile(szInputFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); DWORD size = GetFileSize(hFile, &size); BYTE *buffer = (BYTE *)malloc(size); DWORD read; if(ReadFile(hFile, buffer, size, &read, NULL) == 0) { printf("ReadFile(%s) Failed\n", szInputFile); return 1; } int cbFileHeader = sizeof(BITMAPFILEHEADER);
// Store the size of the BITMAPINFO BITMAPFILEHEADER *pBm = (BITMAPFILEHEADER*)buffer; DWORD cbBitmapInfo = pBm->bfOffBits - cbFileHeader;
// Store a pointer to the BITMAPINFO BITMAPINFO *pBmi = (BITMAPINFO*)(buffer + cbFileHeader); BITMAPINFOHEADER *pBmiHdr = (BITMAPINFOHEADER*)(buffer + cbFileHeader);
// Store a pointer to the starting address of the pixel bits BYTE * Image = buffer + cbFileHeader + cbBitmapInfo;
// Close and invalidate the file handle, since we have copied its bitmap data CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE;
// create a profo mamger IWMProfileManager* pProfileManager; IWMProfile* pProfile; hr = WMCreateProfileManager(&pProfileManager ); // create a profile if(pProfileManager) { hr = pProfileManager->CreateEmptyProfile(WMT_VER_9_0, &pProfile); if(FAILED(hr)) { SAFE_RELEASE(pProfileManager ); return 1; } }
IWMStreamConfig* pConfig; // create a stream for the profile: hr = pProfile->CreateNewStream(WMMEDIATYPE_Image,&pConfig); if( FAILED(hr)) return 1; //set stream name and all the connection name: if(pConfig) { hr = pConfig->SetStreamName(L"bitmapImageStream"); } if(FAILED(hr)) return 1; // configure a connect name for the stream hr = pConfig-> SetConnectionName(L"VideoImg"); if(FAILED(hr)) return 1; /// configure a strean number s from 1 - 63 hr = pConfig->SetStreamNumber(1); if(FAILED(hr)) return 1;
// set bit rate hr=pConfig->SetBitrate(100); if(FAILED(hr)) return 1;
// set window size hr =pConfig->SetBufferWindow(3000); if(FAILED(hr)) return 1;
//******************* configure media type for image **************//
WM_MEDIA_TYPE *wmtMediaType = new WM_MEDIA_TYPE; ZeroMemory( wmtMediaType, sizeof( wmtMediaType ) ); WMVIDEOINFOHEADER vihVideoInfo;
IWMMediaProps* pMediaProps = NULL;
hr = pConfig->QueryInterface( IID_IWMMediaProps, (void**) &pMediaProps ); if ( FAILED( hr ) ) { return 1; } // Set up the WMVIDEOINFOHEADER structure ZeroMemory( &vihVideoInfo, sizeof( vihVideoInfo ) ); vihVideoInfo.rcSource.left = 0; vihVideoInfo.rcSource.top = 0; vihVideoInfo.rcSource.bottom = pBmiHdr->biHeight; vihVideoInfo.rcSource.right = pBmiHdr->biWidth; // it seems stream of image doesn't // accept width <200 vihVideoInfo.rcTarget = vihVideoInfo.rcSource; vihVideoInfo.dwBitRate=100; // same value as above vihVideoInfo.dwBitErrorRate = 0; vihVideoInfo.AvgTimePerFrame = 0;
vihVideoInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER ); vihVideoInfo.bmiHeader.biWidth = pBmiHdr->biWidth; vihVideoInfo.bmiHeader.biHeight = pBmiHdr->biHeight; vihVideoInfo.bmiHeader.biPlanes = 1; vihVideoInfo.bmiHeader.biBitCount = pBmiHdr->biBitCount; vihVideoInfo.bmiHeader.biCompression = BI_RGB; vihVideoInfo.bmiHeader.biSizeImage = pBmiHdr->biSizeImage; vihVideoInfo.bmiHeader.biXPelsPerMeter = 0; vihVideoInfo.bmiHeader.biYPelsPerMeter = 0; vihVideoInfo.bmiHeader.biClrUsed = 0; vihVideoInfo.bmiHeader.biClrImportant = 0;
// Set up the WM_MEDIA_TYPE structure wmtMediaType->majortype = WMMEDIATYPE_Image; wmtMediaType->subtype = WMMEDIASUBTYPE_RGB24; wmtMediaType->bFixedSizeSamples = FALSE; wmtMediaType->bTemporalCompression = FALSE; wmtMediaType->lSampleSize = 0; wmtMediaType->formattype = WMFORMAT_VideoInfo; wmtMediaType->pUnk = NULL; wmtMediaType->cbFormat = sizeof( WMVIDEOINFOHEADER ); wmtMediaType->pbFormat = (unsigned char *)new WMVIDEOINFOHEADER; wmtMediaType->pbFormat = (unsigned char *) &vihVideoInfo;
// Return a copy of the media type to the caller
// set media type hr = pMediaProps->SetMediaType( wmtMediaType ); if( hr==E_OUTOFMEMORY) { printf("outofMemory"); }
if( hr== E_INVALIDARG) { printf(" pValue is null"); }
// add stream profile hr = pProfile->AddStream(pConfig ); if( FAILED( hr ) ) { return( hr ); } SAFE_RELEASE(pConfig); SAFE_RELEASE(pMediaProps);
/// create a writer IWMWriter * m_pWriter=NULL; hr = WMCreateWriter( NULL, &m_pWriter ); if( FAILED( hr ) ) { return( hr ); } /// set writer profile hr = m_pWriter->SetProfile( pProfile ); if( FAILED( hr ) ) { return( hr ); }
SAFE_RELEASE(pProfile);
// working with the input: set the input properties the same as
IWMInputMediaProps * pInputProps = NULL; WCHAR* pwszConnectionName = NULL; DWORD cInputs = 0; WORD cchName = 0; hr = m_pWriter->GetInputCount( &cInputs ); // verify if the input name match iwth the stream name: for( DWORD i = 0; i < cInputs; i++ ) // here cInputs= 1; { hr = m_pWriter->GetInputProps( i, &pInputProps ); if( FAILED( hr ) ) return( hr );
hr = pInputProps->GetConnectionName(0, &cchName); if(cchName<=0) return 1; pwszConnectionName= new WCHAR [cchName]; /// get connection name of the stream hr = pInputProps->GetConnectionName(pwszConnectionName, &cchName); printf("Input # %d = %S\n", cchName, pwszConnectionName); if( FAILED( hr ) ) { break; }
if(pwszConnectionName) { delete pwszConnectionName; pwszConnectionName=NULL; }
/**** Here i was just checking wheather Stream is set properly or not.****/ /*/////////////////*********************************************** WM_MEDIA_TYPE *wmmType = NULL; DWORD psType;
hr = pInputProps->GetMediaType(NULL, &psType); if( FAILED( hr ) ) { printf("GetMediaType failed\n"); return( hr ); }
wmmType = (WM_MEDIA_TYPE*)new BYTE[psType];
hr = pInputProps->GetMediaType(wmmType, &psType); if( FAILED( hr ) ) { printf("GetMediaType failed\n"); return( hr ); }
if(wmmType->majortype == WMMEDIATYPE_Image) printf("Set properly\n"); ///////////////// ************************************************/
SAFE_RELEASE(pInputProps);
// g_wszJPEGCompressionQuality for still image IWMWriterAdvanced2 *pWMWA2 = NULL; hr = m_pWriter->QueryInterface(IID_IWMWriterAdvanced2, (void**)&pWMWA2); if (SUCCEEDED(hr)) { DWORD value = 10; WMT_ATTR_DATATYPE wmt_type = WMT_TYPE_WORD; hr = pWMWA2->SetInputSetting(i, g_wszJPEGCompressionQuality, wmt_type , (BYTE*)&value,sizeof(WORD));
}
}
// Set the output file of the writer hr = m_pWriter->SetOutputFilename( szOutFile ); if( FAILED( hr ) ) { return( hr ); } // before feed the sample call hr = m_pWriter->BeginWriting(); if( FAILED(hr)) return 1;
DWORD cnsSampleTime = 1000; for( int k=0; k<1; k++) { // pass a sample to the writer
/// Allocate a buffer and retrieve a pointer to the INSSBuffer interface DWORD dwSampleSize=pBmiHdr->biHeight*pBmiHdr->biWidth*3 ;
// when we have the image then we can have it INSSBuffer* pSample =NULL; // buffer to contain the image to pass hr = m_pWriter->AllocateSample(dwSampleSize,&pSample); if(FAILED(hr) || !pSample) return 1; ///Retrieve the address of the buffer created in step above BYTE* pdwBuffer=NULL; DWORD dwLeng; hr = pSample->GetBufferAndLength(&pdwBuffer,&dwLeng); if(FAILED(hr)) return 1; ///Copy sample data to the buffer location, making sure that the sample memcpy( pdwBuffer, pBmiHdr, dwLeng); hr = pSample->SetLength(dwLeng);
hr = m_pWriter ->WriteSample (0 ,cnsSampleTime,WM_SF_CLEANPOINT,pSample);
if( hr == S_OK) printf("Sample written\n");
else if( hr == E_INVALIDARG) printf("The dwInputNum value is greater than the highest index number %d\n", k);
else if( hr== E_UNEXPECTED) printf(" The method failed for an unspecified reason\n");
else if( hr== NS_E_NOT_CONFIGURED) printf(" Not configured properly %d\n", k);
else if( hr == NS_E_INVALID_DATA) printf("The sample is not valid \n");
else if( hr == NS_E_INVALID_NUM_PASSES) printf("The wrong number of preprocessing passes\n");
else if( hr == NS_E_TOO_MUCH_DATA ) printf("Samples from a real-time source are arriving\n ");
/* if( hr == NS_LATE_OPERATION) printf("NS_LATE_OPERATION\n");*/
cnsSampleTime+=100000; SAFE_RELEASE(pSample); }
hr = m_pWriter->EndWriting();
SAFE_RELEASE(m_pWriter);
return 0; }
|
|
Why guys you are not replying to my question, why is it not a genuine question?
|
|
On May 2, 11:18 am, vishy <vishwanath.kine...[ at ]gmail.com> wrote:
[Quoted Text] > Why guys you are not replying to my question, why is it not a genuine > question?
Hi Alessandro Angeli,
As i build this application from VS2005, i got the error message "First-chance exception at 0x086d7a94 in test4.exe: 0xC0000005: Access violation writing location 0x00000000". After running SetProfile method. I thisnk you got the sufficient information now.
Thanks Vishy
|
|
On 1 May 2007 23:18:23 -0700, vishy <vishwanath.kinekar[ at ]gmail.com> wrote:
[Quoted Text] > >Why guys you are not replying to my question, why is it not a genuine >question?
This is a peer support group. That is, it's only members of the public in general who post in here. Alessandro is the only person I know who's likely to know the answer to your question. Perhaps like the rest of us, he deserves (and has taken) a holiday ?
Cheers - Neil ------------------------------------------------ Digital Media MVP : 2004-2007 http://mvp.support.microsoft.com/mvpfaqs
|
|
On 1 May 2007 23:25:37 -0700, vishy wrote:
[Quoted Text] > As i build this application from VS2005, i got the error > message "First-chance exception at 0x086d7a94 in test4.exe: > 0xC0000005: Access violation writing location 0x00000000". After > running SetProfile method. I thisnk you got the sufficient information > now.
It's probably the format SDK being dumb. As of release 9.0 and higher, it generates first chance exceptions by the gross load. You have no choice but to ignore these exceptions.
-- http://www.chrisnet.net/code.htm [MS MVP for DirectShow / MediaFoundation]
|
|
[Quoted Text] > It's probably the format SDK being dumb. As of release 9.0 and higher, it > generates first chance exceptions by the gross load. You have no choice > but to ignore these exceptions.
But because of this exception, i think SetProfile is failing to do its job and WriteSample is returning "NS_E_NOT_CONFIGURED".
|
|
[Quoted Text] > This is a peer support group. That is, it's only members of the public > in general who post in here. Alessandro is the only person I know > who's likely to know the answer to your question. Perhaps like the > rest of us, he deserves (and has taken) a holiday ?
No he is not on holiday, becoz he is replying for other posts. If you personally know him, tell him to answer my question. Becoz i struck in this problem for past 1 week. And without this i cant continue.
|
|
On 2 May 2007 22:03:17 -0700, vishy wrote:
[Quoted Text] >> It's probably the format SDK being dumb. As of release 9.0 and higher, it >> generates first chance exceptions by the gross load. You have no choice >> but to ignore these exceptions. > > But because of this exception, i think SetProfile is failing to do its > job and WriteSample is returning "NS_E_NOT_CONFIGURED".
More likely it doesn't like your profile. What was the HRESULT from SetProfile()?
Even with a successful SetProfile you can see the exceptions.
-- http://www.chrisnet.net/code.htm [MS MVP for DirectShow / MediaFoundation]
|
|
|
[Quoted Text] > More likely it doesn't like your profile. What was the HRESULT from > SetProfile()? > > Even with a successful SetProfile you can see the exceptions.
might be :), SetProfile is returning 0 ie(S_OK). As you said its giving exception even with successful return.
|
|
From: "vishy"
[Quoted Text] >> to your question. Perhaps like the rest of us, he >> deserves (and has taken) a holiday ?
I wish :-)
> No he is not on holiday, becoz he is replying for other > posts.
However that doesn't mean I have time to look further into your problem. Since I don't have a solution ready, I would have to write code to reproduce the error and then fix it but I do not have the time to do it, otherwise I already would have done so, that's why I am only replying to "easy" questions.
> If you personally know him, tell him to answer my > question.
Neil can tell me, but I don't have to listen :-P
> Becoz i struck in this problem for past 1 week. > And without this i cant continue.
I am sorry, but you need to either find a solution yourself, keep hoping that somebody has the time and knowledge to find it on your behalf on his/her own schedule, open a support incident with Microsoft or pay someone to write the code for you. Free Usenet support is good, but sometimes it is not enough and you have to make peace with this fact.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
From: "Alessandro Angeli"
[Quoted Text] > I am sorry, but you need to either find a solution > yourself, keep hoping that somebody has the time and > knowledge to find it on your behalf on his/her own > schedule, open a support incident with Microsoft or pay > someone to write the code for you. Free Usenet support is > good, but sometimes it is not enough and you have to make > peace with this fact.
By the way, your post is still marked as unread on my newsreader, because I mean to get back to it when I have time, but that's unlikely to happen in the next 5-6 weeks at least.
-- // Alessandro Angeli // MVP :: DirectShow / MediaFoundation // mvpnews at riseoftheants dot com // http://www.riseoftheants.com/mmx/faq.htm
|
|
[Quoted Text] > First-chance exception in test.exe (WMVCORE.DLL): 0xC0000005: Access > Violation. > > If anyone find the solution for this problem please write down here. > > Thanx > Vishy
I have some experience with DirectShow WMV decoding and I can tell you that WMVCORE.DLL is notoriously bad for spam in the debug output: Precisely these access violation errors. If you open up the disassembly and put breakpoints at the addresses causing the errors you'll find that they occur deep down in Microsoft's decoder, in threads you don't own. It doesn't actually cause a crash AFAIK. They look like exceptions that are getting handled at some point, apparently they're caused by their read stream implementation. It just causes debug spew, which is annoying. All you can do about this is bark at MS until they clean up their own code. Don't worry about it if your program doesn't actually crash. If your program isn't working properly, these error messages are not likely related.
|
|
|