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. hr = pSrcAud->SetInput(bsInputFile) and hr = pEncoder->PrepareToEncode(VARIANT_TRUE); are not working

hr = pSrcAud->SetInput(bsInputFile) and hr = pEncoder->PrepareToEncode(VARIANT_TRUE); are not working

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 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

    both return handle fail. what does it mean? I am using the encoder 9 sdk. I have pick the sample application which comes with sdk . Now when i use the inbuitl sample . it encode the file but when i use that one for changing the following things it gets return handle fail. Look at the change: In sample application ---------------------

    if ( SUCCEEDED( hr ) )
    {
    hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file
    }
    if ( SUCCEEDED( hr ) )
    {
    hr = pSrcVid->SetInput(CComBSTR("C:\\InputFile.mpg"));
    }

    my change ---------------

    WCHAR * pwszOutFile = NULL;
    WCHAR * pwszInFile = NULL;

    //input file and output file come from console
    for(int i=0;i= argc )
    {
    break;
    }

                hr = ConvertTCharToWChar( argv\[i\], &pwszInFile );
                if( FAILED( hr ) )
                {
                    break;
                }
            }
            else if ( 0 == \_tcsicmp( argv\[i\], \_T( "-o" ) ) )
            {
                i++;
                if( i >= argc )
                {
                    break;
                }
    
                hr = ConvertTCharToWChar( argv\[i\], &pwszOutFile );
                if( FAILED( hr ) )
                {
                    break;
                }
            }
    	
    
    }
    

    CComBSTR bsInputFile;

    bsInputFile.Attach ( W2BSTR(pwszInFile ) );

    if ( SUCCEEDED( hr ) )
    {
    hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890
    }

    I had try to find so many times in the google, but unable to find the solution. the preparetoEncodemethod works for console but when i am using the same thing for the window. it give me the E_UNEXPECTED result in the hr.

    "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

    M 1 Reply Last reply
    0
    • A amitmistry_petlad

      both return handle fail. what does it mean? I am using the encoder 9 sdk. I have pick the sample application which comes with sdk . Now when i use the inbuitl sample . it encode the file but when i use that one for changing the following things it gets return handle fail. Look at the change: In sample application ---------------------

      if ( SUCCEEDED( hr ) )
      {
      hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file
      }
      if ( SUCCEEDED( hr ) )
      {
      hr = pSrcVid->SetInput(CComBSTR("C:\\InputFile.mpg"));
      }

      my change ---------------

      WCHAR * pwszOutFile = NULL;
      WCHAR * pwszInFile = NULL;

      //input file and output file come from console
      for(int i=0;i= argc )
      {
      break;
      }

                  hr = ConvertTCharToWChar( argv\[i\], &pwszInFile );
                  if( FAILED( hr ) )
                  {
                      break;
                  }
              }
              else if ( 0 == \_tcsicmp( argv\[i\], \_T( "-o" ) ) )
              {
                  i++;
                  if( i >= argc )
                  {
                      break;
                  }
      
                  hr = ConvertTCharToWChar( argv\[i\], &pwszOutFile );
                  if( FAILED( hr ) )
                  {
                      break;
                  }
              }
      	
      
      }
      

      CComBSTR bsInputFile;

      bsInputFile.Attach ( W2BSTR(pwszInFile ) );

      if ( SUCCEEDED( hr ) )
      {
      hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890
      }

      I had try to find so many times in the google, but unable to find the solution. the preparetoEncodemethod works for console but when i am using the same thing for the window. it give me the E_UNEXPECTED result in the hr.

      "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
      #2

      What is ConvertTCharToWChar? Have you looked at bsInputFile in the debugger to see if it's valid?

      "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

      A 1 Reply Last reply
      0
      • M Mark Salsbery

        What is ConvertTCharToWChar? Have you looked at bsInputFile in the debugger to see if it's valid?

        "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
        #3

        Mark Salsbery wrote:

        What is ConvertTCharToWChar?

        HRESULT ConvertTCharToWChar( TCHAR * ptszInput, WCHAR ** pwszOutput )
        {
            int cchOutput = 0;
            
            if( NULL == ptszInput || NULL == pwszOutput )
            {
                return( E_INVALIDARG );
            }
        
            //
            // Get output buffer size
            //
        #ifdef UNICODE
            cchOutput = wcslen( ptszInput ) + 1;
        #else //UNICODE
            cchOutput = MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, NULL, 0 );
            if( 0 == cchOutput )
            {
                return( HRESULT_FROM_WIN32( GetLastError() ) );
            }
        #endif // UNICODE
        
            *pwszOutput = new WCHAR[ cchOutput ];
            if( NULL == *pwszOutput)
            {
                return( E_OUTOFMEMORY );
            }
        
        #ifdef UNICODE
            wcsncpy( *pwszOutput, ptszInput, cchOutput );
        #else //UNICODE
            if( 0 == MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, *pwszOutput, cchOutput ) )
            {
                SAFE_ARRAYDELETE( *pwszOutput );
                return( HRESULT_FROM_WIN32( GetLastError() ) );
            }        
        #endif // UNICODE
        
            return( S_OK );
        }
        

        Have you looked at bsInputFile in the debugger to see if it's valid?

        yes , The value comes valid.

        "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

        M 1 Reply Last reply
        0
        • A amitmistry_petlad

          Mark Salsbery wrote:

          What is ConvertTCharToWChar?

          HRESULT ConvertTCharToWChar( TCHAR * ptszInput, WCHAR ** pwszOutput )
          {
              int cchOutput = 0;
              
              if( NULL == ptszInput || NULL == pwszOutput )
              {
                  return( E_INVALIDARG );
              }
          
              //
              // Get output buffer size
              //
          #ifdef UNICODE
              cchOutput = wcslen( ptszInput ) + 1;
          #else //UNICODE
              cchOutput = MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, NULL, 0 );
              if( 0 == cchOutput )
              {
                  return( HRESULT_FROM_WIN32( GetLastError() ) );
              }
          #endif // UNICODE
          
              *pwszOutput = new WCHAR[ cchOutput ];
              if( NULL == *pwszOutput)
              {
                  return( E_OUTOFMEMORY );
              }
          
          #ifdef UNICODE
              wcsncpy( *pwszOutput, ptszInput, cchOutput );
          #else //UNICODE
              if( 0 == MultiByteToWideChar( CP_ACP, 0, ptszInput, -1, *pwszOutput, cchOutput ) )
              {
                  SAFE_ARRAYDELETE( *pwszOutput );
                  return( HRESULT_FROM_WIN32( GetLastError() ) );
              }        
          #endif // UNICODE
          
              return( S_OK );
          }
          

          Have you looked at bsInputFile in the debugger to see if it's valid?

          yes , The value comes valid.

          "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
          #4

          Well if the string is valid at the time of the call, and it's exactly the same as when you use the sample code, then it should work. It's impossible for us to debug - you have to do it :)

          "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

          A 1 Reply Last reply
          0
          • M Mark Salsbery

            Well if the string is valid at the time of the call, and it's exactly the same as when you use the sample code, then it should work. It's impossible for us to debug - you have to do it :)

            "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

            Thanks for you nice smile :). but I really need your help can you give the proper time so can we seat together? for solving the problem?

            "Success lies not in the result , But in the efforts !!!!!" Amit Mistry - petlad -Gujarat-India

            M 1 Reply Last reply
            0
            • A amitmistry_petlad

              Thanks for you nice smile :). but I really need your help can you give the proper time so can we seat together? for solving the problem?

              "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

              If that's really the only change you made from the sample code, and the sample code worked, then you should be able to debug it fairly easily. I would start at the line you marked in red and comment it out and add the line from the working code, like this: //hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890 hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file If it doesn't work, then something is broken somewhere else. If it works, then switch the code to your new code: hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890 //hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file Put a breakpoint here and check bsInputFile in the debugger. It should be the EXACT string that worked in the sample code ("C:\InputFile.mpg" in your posted code). If the project is fairly small and you have a complete buildable solution for VS 2003 or below, I can look at the code if you want to send it. Email me. 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

                If that's really the only change you made from the sample code, and the sample code worked, then you should be able to debug it fairly easily. I would start at the line you marked in red and comment it out and add the line from the working code, like this: //hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890 hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file If it doesn't work, then something is broken somewhere else. If it works, then switch the code to your new code: hr = pSrcAud->SetInput(bsInputFile); //Handle return hr=-2147012890 //hr = pSrcAud->SetInput(CComBSTR("C:\\InputFile.mpg")); //this is a standard file Put a breakpoint here and check bsInputFile in the debugger. It should be the EXACT string that worked in the sample code ("C:\InputFile.mpg" in your posted code). If the project is fairly small and you have a complete buildable solution for VS 2003 or below, I can look at the code if you want to send it. Email me. 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

                Thank you very much for this guideline. and support. :rose: :rose: if this will not run then I will email you. Thank you once again Dear Mark .

                "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