Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. file encoding problem

file encoding problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amitmistry_petlad
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • A amitmistry_petlad

      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

      P Offline
      P Offline
      Paresh Chitte
      wrote on last edited by
      #2

      What kind of encoding are you using ? Could you please share your code ? Regards, Paresh.

      A 1 Reply Last reply
      0
      • P Paresh Chitte

        What kind of encoding are you using ? Could you please share your code ? Regards, Paresh.

        A Offline
        A Offline
        amitmistry_petlad
        wrote on last edited by
        #3

        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
        
        M 1 Reply Last reply
        0
        • A amitmistry_petlad

          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
          
          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          :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

          A 1 Reply Last reply
          0
          • M Mark Salsbery

            :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

            A Offline
            A Offline
            amitmistry_petlad
            wrote on last edited by
            #5

            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

            M 1 Reply Last reply
            0
            • A amitmistry_petlad

              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

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              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

              A 1 Reply Last reply
              0
              • M Mark Salsbery

                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

                A Offline
                A Offline
                amitmistry_petlad
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups