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:
// Make sure we have a valid file.
if ( m_pAviFile == NULL )
// Create the bitmap.
if ( m_pAviBitmap != NULL )
m_pAviBitmap = new CBitmap();
// Copy the view to the bitmap.
GetClientRect( &rect );
dc.CreateCompatibleDC( pDC );
( &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->GetSafeHand
// Make sure everything is ok.
if ( hResult != S_OK )
strError.Format( _T( "Could not create the AVI file: \n%s" ),
AfxMessageBox( strError );
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.