Windows Media Encoder Events Do Not Fire (282521)
The information in this article applies to:
- Microsoft Windows Media Encoder 7
This article was previously published under Q282521 SYMPTOMS
Events do not fire in the Windows Media Encoder.
CAUSE
The Windows Media Encoder message pump thread needs time to initialize.
RESOLUTION
To resolve this problem, do one of the following:
- If the application is a console mode application and COM is initialized in Single Threaded Apartment (STA) mode (CoInitialize( NULL ) ), the application must pump messages after it starts encoding. To accomplish this, add the following code after you start the Encoder:
hr = pEncoder->Start();
// MsgLoop is necessary to receive messages
while (true)
{
sec++;
if(sec == 30)
break;
else
{
while(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Sleep(1000); // Sleep for 1 sec
}
}
pEncoder->Stop();
-OR-
- If the application is a Windows-based application and COM is initialized in STA mode (CoInitialize( NULL ) ), add the following function and call before calling PrepareToEncode on the Encoder. This ensures that the Encoder has enough time to initialize.
void EncoderInitialization()
{
//
// Allow encoder init
//
int sec = 0 ;
MSG msg;
while (true)
{
sec++;
if(sec == 15)
break;
else
{
while ( PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Sleep(500);
}
}
}
STATUSMicrosoft has confirmed that this is a problem in Microsoft Windows Media Encoder version 7.0.
This issue has been resolved with Windows Media Encoder 7.1. To upgrade to version 7.1, see the following Microsoft Web site:
MORE INFORMATION
There are two threads: the main encoder thread and the message pump thread. The message pump thread creates a window and passes the window handle back to the main thread. The window handle is set onto the main thread after Encoder creation. In this case, the main thread is not giving the message pump thread any time to set the window handle.
A known symptom of this problem is that automatic indexing does not occur after the encoding is completed. The suggested changes in the "Resolution" section will resolve this problem.
For additional information, see the Windows Media Encoder SDK.
Modification Type: | Major | Last Reviewed: | 5/24/2001 |
---|
Keywords: | kbbug KB282521 |
---|
|