file encoding problem
-
well I have build entire application but some where I got failure to encode the file. can any body help me? The application working nice for the console application. but failure for window. when I run the application first time it can made the converted file but no data. and when I click button "Encode File" second time. no result i havent got the file. welcome for look at code. its simple one function.
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
-
well I have build entire application but some where I got failure to encode the file. can any body help me? The application working nice for the console application. but failure for window. when I run the application first time it can made the converted file but no data. and when I click button "Encode File" second time. no result i havent got the file. welcome for look at code. its simple one function.
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
What kind of encoding are you using ? Could you please share your code ? Regards, Paresh.
-
What kind of encoding are you using ? Could you please share your code ? Regards, Paresh.
Encoding from any format to wmv/wma by encoder sdk by c++ please check the link http://www.codeproject.com/Purgatory/ConvertVideoFileFormats.asp[^] this in c# while i am in vc++ pEncoder->PrepareToEncode-failed most time
HRESULT Encoder :: convertintowma_wmv(WCHAR *source,WCHAR * destionation,WCHAR * w_encoderprofile,BOOL b_MultiPass,UINT top ,UINT bottom ,UINT left,UINT right,HACCEL hAccelTable)
{HRESULT hr; IWMEncoder\* pEncoder; IWMEncSourceGroupCollection\* pSrcGrpColl=NULL; IWMEncSourceGroup\* pSrcGrp=NULL; IWMEncSource\* pSrc=NULL; IWMEncSource\* pSrcAud=NULL; IWMEncVideoSource\* pSrcVid=NULL; IWMEncProfileCollection\* pProColl=NULL; IWMEncProfile\* pPro=NULL; IWMEncFile\* pFile=NULL; IWMEncAttributes\* pAttr=NULL; IWMEncDisplayInfo\* pDispInfo=NULL; CComBSTR bstrName = NULL; CComVariant varIndex; CCallBack EventSink; WMENC\_ENCODER\_STATE enumCurState; WMENC\_ENCODER\_STATE enumPrvState; short iAudCount, iVidCount; long lCount=0; int i=0;
// enumCurState=0;
// enumPrvState=0;// Initialize the COM library and retrieve a pointer to an IWMEncoder interface. hr = CoInitialize(NULL); if ( SUCCEEDED( hr ) ) { hr = CoCreateInstance(CLSID\_WMEncoder, NULL, CLSCTX\_INPROC\_SERVER, IID\_IWMEncoder, (void\*\*) &pEncoder); }else { MessageBox(0,L"FAIL CREATE instance",L"FAIL CREATE instance",0); } // Retrieve the source group collection. if ( SUCCEEDED( hr ) ) { hr = pEncoder->get\_SourceGroupCollection(&pSrcGrpColl); }else { MessageBox(0,L"pEncoder->get\_SourceGroupCollection Fail",L"get\_SourceGroupCollection",0); } // Add a source group to the collection. if ( SUCCEEDED( hr ) ) { hr = pSrcGrpColl->Add(CComBSTR("SG\_1"), &pSrcGrp); } else { MessageBox(0,L"pSrcGrpColl->Add",L"pSrcGrpColl->Add",0); } if ( SUCCEEDED( hr ) ) { hr = pSrcGrp->AddSource(WMENC\_AUDIO, &pSrcAud); }else { MessageBox(0,L"pSrcGrp->AddSource",L"pSrcGrp->AddSource",0); } if ( SUCCEEDED( hr ) ) { hr = pSrcGrp->AddSource(WMENC\_VIDEO, &pSrc); }else { MessageBox(0,L"pSrcGrp->AddSource(WMENC\_VIDEO",L"pSrcGrp->AddSource(WM
-
Encoding from any format to wmv/wma by encoder sdk by c++ please check the link http://www.codeproject.com/Purgatory/ConvertVideoFileFormats.asp[^] this in c# while i am in vc++ pEncoder->PrepareToEncode-failed most time
HRESULT Encoder :: convertintowma_wmv(WCHAR *source,WCHAR * destionation,WCHAR * w_encoderprofile,BOOL b_MultiPass,UINT top ,UINT bottom ,UINT left,UINT right,HACCEL hAccelTable)
{HRESULT hr; IWMEncoder\* pEncoder; IWMEncSourceGroupCollection\* pSrcGrpColl=NULL; IWMEncSourceGroup\* pSrcGrp=NULL; IWMEncSource\* pSrc=NULL; IWMEncSource\* pSrcAud=NULL; IWMEncVideoSource\* pSrcVid=NULL; IWMEncProfileCollection\* pProColl=NULL; IWMEncProfile\* pPro=NULL; IWMEncFile\* pFile=NULL; IWMEncAttributes\* pAttr=NULL; IWMEncDisplayInfo\* pDispInfo=NULL; CComBSTR bstrName = NULL; CComVariant varIndex; CCallBack EventSink; WMENC\_ENCODER\_STATE enumCurState; WMENC\_ENCODER\_STATE enumPrvState; short iAudCount, iVidCount; long lCount=0; int i=0;
// enumCurState=0;
// enumPrvState=0;// Initialize the COM library and retrieve a pointer to an IWMEncoder interface. hr = CoInitialize(NULL); if ( SUCCEEDED( hr ) ) { hr = CoCreateInstance(CLSID\_WMEncoder, NULL, CLSCTX\_INPROC\_SERVER, IID\_IWMEncoder, (void\*\*) &pEncoder); }else { MessageBox(0,L"FAIL CREATE instance",L"FAIL CREATE instance",0); } // Retrieve the source group collection. if ( SUCCEEDED( hr ) ) { hr = pEncoder->get\_SourceGroupCollection(&pSrcGrpColl); }else { MessageBox(0,L"pEncoder->get\_SourceGroupCollection Fail",L"get\_SourceGroupCollection",0); } // Add a source group to the collection. if ( SUCCEEDED( hr ) ) { hr = pSrcGrpColl->Add(CComBSTR("SG\_1"), &pSrcGrp); } else { MessageBox(0,L"pSrcGrpColl->Add",L"pSrcGrpColl->Add",0); } if ( SUCCEEDED( hr ) ) { hr = pSrcGrp->AddSource(WMENC\_AUDIO, &pSrcAud); }else { MessageBox(0,L"pSrcGrp->AddSource",L"pSrcGrp->AddSource",0); } if ( SUCCEEDED( hr ) ) { hr = pSrcGrp->AddSource(WMENC\_VIDEO, &pSrc); }else { MessageBox(0,L"pSrcGrp->AddSource(WMENC\_VIDEO",L"pSrcGrp->AddSource(WM
:omg: Have you stepped through the entire function in the debugger to make sure all preceding calls were successful? I can't tell entirely what's going on because of indentation, but is PrepareToEncode(VARIANT_FALSE) being called before PrepareToEncode(VARIANT_TRUE)? If so, that seems odd to me. When IWMEncoder::PrepareToEncode() fails, you can use the IErrorInfo interface to get a description of the error:
#include <atlbase.h>
#include <atlcomcli.h>
...
hr = pEncoder->PrepareToEncode(VARIANT_TRUE);if (FAILED(hr)
{
CComPtr<IErrorInfo> pEO;
if(S_OK == GetErrorInfo(NULL, &pEO))
{
CComBSTR bstrDesc;
pEO->GetDescription(&bstrDesc);// examine this BSTR
}
}"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
:omg: Have you stepped through the entire function in the debugger to make sure all preceding calls were successful? I can't tell entirely what's going on because of indentation, but is PrepareToEncode(VARIANT_FALSE) being called before PrepareToEncode(VARIANT_TRUE)? If so, that seems odd to me. When IWMEncoder::PrepareToEncode() fails, you can use the IErrorInfo interface to get a description of the error:
#include <atlbase.h>
#include <atlcomcli.h>
...
hr = pEncoder->PrepareToEncode(VARIANT_TRUE);if (FAILED(hr)
{
CComPtr<IErrorInfo> pEO;
if(S_OK == GetErrorInfo(NULL, &pEO))
{
CComBSTR bstrDesc;
pEO->GetDescription(&bstrDesc);// examine this BSTR
}
}"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
Dear Mark. Thank you very much for your help and I appreciate that, but what are the basic reasons for unproperwork (pEncoder->PrepareToEncode(VARIANT_TRUE); ) of this function because you know some time its working properly even when the exe is running on my desktop after few seconds its working fine and after few second when i trying to encode its again gone fail. Some time working nice and some time failure. When I debug I got E_UNEXCEPTED at failture time . I have try to check this error with encoder sdk help but no fruitful result
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
-
Dear Mark. Thank you very much for your help and I appreciate that, but what are the basic reasons for unproperwork (pEncoder->PrepareToEncode(VARIANT_TRUE); ) of this function because you know some time its working properly even when the exe is running on my desktop after few seconds its working fine and after few second when i trying to encode its again gone fail. Some time working nice and some time failure. When I debug I got E_UNEXCEPTED at failture time . I have try to check this error with encoder sdk help but no fruitful result
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India
Most of the code you posted looks like it's taken directly from the "Encoding a File (C++)" example in the WME SDK. Calling PrepareToEncode(VARIANT_FALSE) ENDS an encoding session so it makes no sense that the call is in your code (it's not in the example code). Maybe compare your code to the sample code in the SDK and see what you are doing differently. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Most of the code you posted looks like it's taken directly from the "Encoding a File (C++)" example in the WME SDK. Calling PrepareToEncode(VARIANT_FALSE) ENDS an encoding session so it makes no sense that the call is in your code (it's not in the example code). Maybe compare your code to the sample code in the SDK and see what you are doing differently. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
Mark Salsbery wrote:
Calling PrepareToEncode(VARIANT_FALSE) ENDS an encoding session so it makes no sense that the call is in your code (it's not in the example code).
I have wrote that thing becoz of suppose in any case if any old file havent stop then prior it can stop and reset for new one. I have check it without writing this code but it was given the same error.
"Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India