?
Solved

Video encoding problems

Posted on 2011-03-25
2
Medium Priority
?
752 Views
Last Modified: 2013-11-20
Hi Experts,

This is a follow up to my earlier question here:  http://tinyurl.com/6yjccph

I'm having a few problems trying to create an AVI file using the CAviFile class published here:  http://www.codeproject.com/KB/graphics/createmovie.aspx

To start I initialize my AVI file as follows:

      m_pAviFile = new CAviFile( _T( "Test.avi" ),
            mmioFOURCC( _T( 'M' ), _T( 'S' ), _T( 'S' ), _T( '2' ) ), 1 );

Then whenever my CView-derived class is redrawn I call the following code:

void
MyView::UpdateAviFile
(
      CDC* pDC
)
{

      // Make sure we have a valid file.

      if ( m_pAviFile == NULL )
      {
            return;
      }

      // Create the bitmap.

      if ( m_pAviBitmap != NULL )
      {
            delete m_pAviBitmap;
      }

      m_pAviBitmap = new CBitmap();

      // Copy the view to the bitmap.

      CRect rect;
      GetClientRect( &rect );

      CDC dc;
      dc.CreateCompatibleDC( pDC );

      m_pAviBitmap->CreateCompatibleBitmap( &dc, rect.Width(), rect.Height() );
      CBitmap* pOld = ( CBitmap* )dc.SelectObject( m_pAviBitmap );
      dc.BitBlt( 0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY );

      // Try to append the bitmap to the AVI file.

      HRESULT hResult = m_pAviFile->AppendNewFrame(
            ( HBITMAP )m_pAviBitmap->GetSafeHandle() );

      // Make sure everything is ok.

      if ( hResult != S_OK )
      {
            CString strError;
            
            strError.Format( _T( "Could not create the AVI file: \n%s" ),
                  m_pAviFile->GetLastErrorMessage() );

            AfxMessageBox( strError );
            CloseAviFile();
      }

}

The problems I'm having are below.  I'm running on a Vista x64 system.

1.  It seems like the Windows Media Video 9 Screen Codec (MSS2) would be the best one to use for what I am trying to do (see http://msdn.microsoft.com/en-us/library/dd464602(v=vs.85).aspx).  However, I've downloaded both the Windows Media Encoder and the new Microsoft Expression Encoder 4, and neither of these products has installed the MSS2 encoder on my system.  When I look at Windows Media Player / Help / About Windows Media Player / Technical Support Information I can see that only the decoder is installed.  Can anyone tell me where to get the MSS2 encoder?

2.  Alternatively, I thought I could try the MPG4 encoder, but I also couldn't find out where to download it.  Is this available as a free download somewhere?  If not, is there a reputable site that sells this and other encoders?

3.  Two encoders that I see are installed on my system are Microsoft RLE (MRLE) and Microsoft Video 1 (MSVC).  However, when I set up these values in the miniFOURCC parameter I get the error "Unable to Set Video Stream Format" when I first call AppendNewFrame.  I also tried creating the CAviFile with no encoder like this:  m_pAviFile = new CmnAviFile( _T( "Test.avi" ), 0, 1 );  However, this just causes my program to crash.  So I assume there is something wrong with code, does anyone have an idea of what the problem is?

Thanks for any help.

Regards,
Kevin
0
Comment
Question by:kjc1111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Author Comment

by:kjc1111
ID: 35226397
Hi again,

I think I've included too many questions in this post, so I've moved problems 1 and 2 into this new post:  http://tinyurl.com/6f55o6v.  If anyone can help me figure out the problems I'm having with my code and the MRLE and MSVC codecs (problem 3 only) I'll award the points.

Thanks,
Kevin
0
 

Accepted Solution

by:
kjc1111 earned 0 total points
ID: 37087106
I just saw that this question is still open.  For anyone who is interested I eventually got this working.  I ended up creating WMV files instead of AVI files - the process to do this is also described at the CodeProject link.  The WMV encoder uses the MSS2 encoder which I believe was installed when I installed Windows Media Encoder on my computer (although it might be installed by default on Window or with Windows Media Player, I'm not sure).  

The overall process took some time but the comments at the CodeProject link were very helpful.  I think WMV is a better choice anyway; in particular the MSS2 encoder is optimized for capturing screen videos which is what I wanted, so the videos I create are a reasonable size.

Regards,
Kevin
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn key ranges in Sampler to make their sampled instruments sound more realistic Gather samples of various notes and drag them to Key Range panel: Set proper root key for each sample: Select all the samples with Command-A (or Ctrl…
It’s easy to embed any of your public Prezi presentations on your website or social network to share with others. Learn how simple it is in this tutorial.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question