HRESULT CVideoSource: RecoderAVIFrames (char * szFile)
{
HRESULT hr = NULL;
OFSTRUCT OS;
// IBaseFilter * pMux;
IFileSinkFilter * pSink;
IConfigAviMux * pConfigAviMux;
If (OpenFile (szFile, & OS, OF_EXIST) = HFILE_ERROR)
{
// Bring up dialog, and set new file size
/* CFile f;
Bool bFile = f. Open (szFile, CFile: modeCreate | CFile: modeWrite );
If (! BFile)
{
MessageBox (AfxGetMainWnd ()-> m_hWnd, TEXT ("sorry, you cannot create a file. Please check whether the folder has strict control "),
TEXT ("Error "),
MB_ OK | MB_ICONEXCLAMATION );
}*/
Hr = m_pBuilder-> AllocCapFile (LPCOLESTR (szFile), (DWORDLONG) 100*1024*1024 );
If (hr! = NOERROR)
{
MessageBox (AfxGetMainWnd ()-> m_hWnd, TEXT ("Sorry, there is not enough disk space, please adjust disk space "),
TEXT ("Error "),
MB_ OK | MB_ICONEXCLAMATION );
Return FALSE;
}
}
// Hr = m_pBuilder-> SetOutputFileName (& MEDIASUBTYPE_Avi, (LPCOLESTR) szFile, & m_pMux, NULL );
// Hr = m_pBuilder-> SetOutputFileName (& MEDIASUBTYPE_Avi, (LPCOLESTR) szFile, & m_pMux, & pSink );
Hr = m_pBuilder-> SetOutputFileName (& MEDIASUBTYPE_Avi, (LPCOLESTR) szFile, & m_pVideoRender, & pSink );
If (hr! = NOERROR)
{
ErrMsg (TEXT ("Cannot set output file "));
}
// Now tell the AVIMUX to write out AVI files that old apps can read properly.
// If we don't, most apps won't be able to tell where the keyframes are,
// Slowing down editing considerably
// Doing this will cause one seek (over the area the index will go) when
// You capture past 1 Gig, but that's no big deal.
// NOTE: This is on by default, so it's not necessary to turn it on
// Also, set the proper MASTER STREAM
Hr = m_pVideoRender-> QueryInterface (IID_IConfigAviMux, (void **) & pConfigAviMux );
If (hr = NOERROR & pConfigAviMux)
{
Hr = pConfigAviMux-> SetOutputCompatibilityIndex (TRUE );
}
// Render the video capture and preview pins-even if the capture filter only
// Has a capture pin (and no preview pin) this shocould work... because
// Capture graph builder will use a smart tee filter to provide both capture
// And preview. We don't have to worry. It will just work.
//
// NOTE that we try to render the interleaved pin before the video pin, because
// If BOTH exist, it's a DV filter and the only way to get the audio is to use
// The interleaved pin. Using the Video pin on a DV filter is only useful if
// You don't want the audio.
// M_pBuilder-> GetFiltergraph (& m_pGrapher );
// You need to set a sound recording.
/* If (gcap. fCapAudio)
{
Hr = gcap. pConfigAviMux-> SetMasterStream (gcap. iMasterStream );
If (hr! = NOERROR)
ErrMsg (TEXT ("SetMasterStream failed! "));
}*/
Hr = m_pBuilder-> RenderStream (& PIN_CATEGORY_CAPTURE, & MEDIATYPE_Interleaved, m_pVideoCap, NULL, m_pVideoRender );
// Hr = m_pBuilder-> RenderStream (& PIN_CATEGORY_CAPTURE, & MEDIATYPE_Interleaved, m_pVideoCap, NULL, m_pMux );
If (hr! = NOERROR)
{
Hr = m_pBuilder-> RenderStream (& PIN_CATEGORY_CAPTURE, & MEDIATYPE_Video, m_pVideoCap, NULL, m_pVideoRender );
// Hr = m_pBuilder-> RenderStream (& PIN_CATEGORY_CAPTURE, & MEDIATYPE_Video, m_pVideoCap, NULL, m_pMux );
If (hr! = NOERROR)
{
ErrMsg (TEXT ("Cannot render video capture stream "));
}
}
// Tell the file writer to use the new filename
If (m_pFileSink)
{
// M_pFileSink-> SetFileName (T2W (szFile), NULL );
}
StartCapture ();
Return hr;
}