We have an application that controls the windows encoder. It was written in C++ using windows encoder SDK. It works fine with encoder 7 but with encoder 9 it crashes with Run Time error. I was able to isolate the problem to a very small piece of code. The following is the sequence(also - please see the code below)
1) Create an encoder object
loop
2) Load it with .wme file(this file works just fine if used through the windows encoder 9 GUI)
3) Start the encoder
4) Stop the encoder
this sequence crashes on the second iteration of Load(everything seems to work fine on the first iteration
I also noticed that the Load function itself is not a problem - I had some methods after stop on which the program would crash...seems to be some kind of memory corruption. Please help
#import "c:\Program Files\Windows Media Components\Encoder\WMEnc.exe" no_namespace named_guid
#import "c:\Program Files\Windows Media Components\Encoder\MSPShell.dll" no_namespace named_guid
#include <stdio.h
#include <windows.h
#include <atlbase.h
#include <comdef.h
#include "RemoteEncoder.h
IWMEncoder* encoder = NULL
void HandleStartEncoder (
if(encoder == NULL
printf("encoder is null\n")
// First check if the encoder is still running
WMENC_ENCODER_STATE encstate = encoder->GetRunState()
if(encstate == WMENC_ENCODER_RUNNING || encstate == WMENC_ENCODER_STARTING
printf( "Encoder still running")
else printf("encoder is stopped\n")
///////////////////////////////////////////////////////////////////
// Load in WME template if it exists
///////////////////////////////////////////////////////////////////
const char* wmefilename
_bstr_t wmepath
wmefilename = "c:\\encoder\\encoder.wme"
wmepath = wmefilename
encoder->Load(wmepath)
encoder->Start()
HRESULT hr = encoder->get_RunState(&encstate)
if (encstate != WMENC_ENCODER_RUNNING && encstate != WMENC_ENCODER_STARTING)
printf("encoder not running\n")
} else
printf("encoder running\n")
encoder->Stop()
hr = encoder->get_RunState(&encstate)
if (encstate != WMENC_ENCODER_RUNNING && encstate != WMENC_ENCODER_STARTING)
printf("encoder stopped\n")
} else
printf("encoder did not stop")
// return S_OK
void main()
HRESULT hr = S_OK
hr = CoInitialize(NULL)
if ( SUCCEEDED( hr )
hr = CoCreateInstance(CLSID_WMEncoder
NULL
CLSCTX_INPROC_SERVER
IID_IWMEncoder
(void**) &encoder)
for (int i = 0; i < 100; i++
HandleStartEncoder()
// Release pointers
if ( encoder
encoder->Release()
encoder = NULL
...and here is the .wme file
<?xml version="1.0"?><WMEncoder major_version="9
minor_version="0
Name="WMEncoder15080
SynchroniesOperation="0" ><Description /><SourceGroups ><SourceGroup Name="Live" ><Source Type="WMENC_VIDEO
Scheme="device
InputSource="Default_Video_Device" ><UserData ><WMENC_BOOL Name="UseRecordQueue" Value="no" /><WMENC_STRING Name="RecordTempPath" Value="C:\DOCUME~1\arodkin\LOCALS~1\Temp\" /><WMENC_STRING Name="MinimumDiskSpace" Value="10485760" /><WMENC_BOOL Name="SaveToDiskOnlyDuringCapture" Value="no" /></UserData></Source><Source Type="WMENC_AUDIO
Scheme="device
InputSource="Default_Audio_Device" ><UserData ><WMENC_BOOL Name="UseRecordQueue" Value="no" /><WMENC_STRING Name="RecordTempPath" Value="C:\DOCUME~1\arodkin\LOCALS~1\Temp\" /><WMENC_STRING Name="MinimumDiskSpace" Value="10485760" /><WMENC_BOOL Name="SaveToDiskOnlyDuringCapture" Value="no" /></UserData></Source><EncoderProfile id="Multiple bit rates audio (CBR) / Multiple bit rates video (CBR)" /><UserData ></UserData></SourceGroup></SourceGroups><Broadcast Http="8080" /><WMEncoder_Profile id="Multiple bit rates audio (CBR) / Multiple bit rates video (CBR)" ><![CDATA[ <profile version="589824"
storageformat="1"
name="Multiple bit rates audio (CBR) / Multiple bit rates video (CBR)"
description=""><streamconfig majortype="{73647561-0000-0010-8000-00AA00389B71}"
streamnumber="1"
streamname="Audio Stream"
inputname="Audio409"
bitrate="32000"
bufferwindow="5000"
reliabletransport="0"
decodercomplexity=""
rfc1766langid="en-us"
><wmmediatype subtype="{00000161-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="1"
btemporalcompression="0"
lsamplesize="768"><waveformatex wFormatTag="353"
nChannels="2"
nSamplesPerSec="32000"
nAvgBytesPerSec="4000"
nBlockAlign="768"
wBitsPerSample="16"
codecdata="008800001700001E0000"/></wmmediatype></streamconfig><streamconfig majortype="{73646976-0000-0010-8000-00AA00389B71}"
streamnumber="2"
streamname="Video Stream"
inputname="Video409"
bitrate="241000"
bufferwindow="5000"
reliabletransport="0"
decodercomplexity="AU"
rfc1766langid="en-us"
><videomediaprops maxkeyframespacing="80000000"
quality="60"/><wmmediatype subtype="{33564D57-0000-0010-8000-00AA00389B71}"
bfixedsizesamples="0"
btemporalcompression="1"
lsamplesize="0"><videoinfoheader dwbitrate="241000"
dwbiterrorrate="0"
avgtimeperframe="333667"><rcsource left="0"
top="0"
right="320"
bottom="240"/><rctarget left="0"
top="0"
right="320"
bottom="240"/><bitmapinfoheader biwidth="320"
biheight="240"
biplanes="1"
bibitcount="24"
bicompression="WMV3"
bisizeimage="0"
bixpelspermeter="0"
biypelspermeter="0"
biclrused="0"
biclrimportant="0"/></videoinfoheader></wmmediatype></streamconfig></profile>
]]></WMEncoder_Profile><UserData ><WMENC_LONG Name="Encoding\Dest" Value="2" /><WMENC_STRING Name="Encoding\Audio0" Value="{41DB0988-374A-4CB6-8929-44BAEA325D03}" /><WMENC_STRING Name="Encoding\Video0" Value="{BB8FC6CB-4E56-474A-BC95-16DD3072AF1A}" /></UserData></WMEncoder
Candace - 14 May 2004 23:06 GMT
I am getting a message in Internet explorer that says that I have a visual c++ runtime library error, it also says program C:\\Windows\explorer.exe and abnormal program termination can you please help me fix this problem. When it happens my computer locks up and i have to reboot.