Click here to Skip to main content
15,904,339 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to open dsw file through my code? Pin
Abhayc15-May-06 18:52
Abhayc15-May-06 18:52 
AnswerRe: How to open dsw file through my code? Pin
John M. Drescher15-May-06 19:08
John M. Drescher15-May-06 19:08 
GeneralRe: How to open dsw file through my code? Pin
Abhayc15-May-06 22:38
Abhayc15-May-06 22:38 
GeneralRe: How to open dsw file through my code? Pin
ThatsAlok15-May-06 22:52
ThatsAlok15-May-06 22:52 
GeneralRe: How to open dsw file through my code? Pin
Abhayc16-May-06 6:36
Abhayc16-May-06 6:36 
QuestionRecord AVI with sound Pin
huutribk200115-May-06 18:08
huutribk200115-May-06 18:08 
AnswerRe: Record AVI with sound Pin
normanS15-May-06 20:08
normanS15-May-06 20:08 
GeneralRe: Record AVI with sound Pin
huutribk200115-May-06 20:21
huutribk200115-May-06 20:21 
Hi,
The follow are some my codes. I finished to write a Avis and wav(write by other thread) then continue to add the wav to Avis file existing.

Please help me for some suggestions and code example.

With the follow code it can write but I can't play final avi file with Window Media, Real Player, it seem to wrong codecs or format

I have used the compression codecs option as MSVC(Mircorsoft Video Codecs 1)
Please help me again.


//Add Frame code
bool CAVIUtil::AppendFrameUsual(HBITMAP hBitmap)
{
BITMAPINFO bmpInfo;

bmpInfo.bmiHeader.biBitCount = 0;
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
GetDIBits(m_hAviDC, hBitmap, 0, 0, NULL, &bmpInfo, DIB_RGB_COLORS);
bmpInfo.bmiHeader.biCompression = BI_RGB;
GetDIBits(m_hAviDC, hBitmap, 0, bmpInfo.bmiHeader.biHeight, m_lpBits, &bmpInfo, DIB_RGB_COLORS);
if (FAILED(AVIStreamWrite(m_pAviCompressedStream, m_lSample++, 1, m_lpBits, bmpInfo.bmiHeader.biSizeImage, 0, NULL, NULL)))
{
strcpy(m_szErrorMessage, "AppendFrameUsual(): AVIStreamWrite failed");
return (false);
}
return (true);
}

//Add wav to avi

HRESULT CAVIUtil::AddAviWav(const char *src)
{
char *buf=0; WavChunk *wav = (WavChunk*)src;
HANDLE hf=CreateFile(src,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
if (hf==INVALID_HANDLE_VALUE) {
MessageBox(NULL,"AVIERR_FILEOPEN","ERROR",MB_OK);
return AVIERR_FILEOPEN;
}
DWORD size = GetFileSize(hf,NULL);
buf = new char[size];
DWORD red; ReadFile(hf,buf,size,&red,NULL);
CloseHandle(hf);
wav = (WavChunk*)buf;

// check that format doesn't clash
bool badformat=false;
if (m_wfx.nChannels==0)
{ m_wfx.wFormatTag=wav->fmt.wFormatTag;
m_wfx.cbSize=0;
m_wfx.nAvgBytesPerSec=wav->fmt.dwAvgBytesPerSec;
m_wfx.nBlockAlign=wav->fmt.wBlockAlign;
m_wfx.nChannels=wav->fmt.wChannels;
m_wfx.nSamplesPerSec=wav->fmt.dwSamplesPerSec;
m_wfx.wBitsPerSample=wav->fmt.wBitsPerSample;
}
else
{
if (m_wfx.wFormatTag!=wav->fmt.wFormatTag) badformat=true;
if (m_wfx.nAvgBytesPerSec!=wav->fmt.dwAvgBytesPerSec) badformat=true;
if (m_wfx.nBlockAlign!=wav->fmt.wBlockAlign) badformat=true;
if (m_wfx.nChannels!=wav->fmt.wChannels) badformat=true;
if (m_wfx.nSamplesPerSec!=wav->fmt.dwSamplesPerSec) badformat=true;
if (m_wfx.wBitsPerSample!=wav->fmt.wBitsPerSample) badformat=true;
}
if (badformat) {if (buf!=0) delete[] buf;
MessageBox(NULL,"AVIERR_BADFORMAT","ERROR",MB_OK);
return AVIERR_BADFORMAT;
}
//
// create the stream if necessary
if(m_pAudioStream==0){
AVISTREAMINFO ahdr; ZeroMemory(&ahdr,sizeof(ahdr));
ahdr.fccType=streamtypeAUDIO;
ahdr.dwScale=m_wfx.nBlockAlign;
ahdr.dwRate=m_wfx.nSamplesPerSec*m_wfx.nBlockAlign;
ahdr.dwSampleSize=m_wfx.nBlockAlign;
ahdr.dwQuality=(DWORD)-1;
HRESULT hr = AVIFileCreateStream(m_pAviFile,&m_pAudioStream, &ahdr);
if (hr!=AVIERR_OK) {if (buf!=0) delete[] buf; return hr;}
hr = AVIStreamSetFormat(m_pAudioStream,0,&m_wfx,sizeof(WAVEFORMATEX));
if (hr!=AVIERR_OK) {if (buf!=0) delete[] buf;return hr;}
}
// now we can write the data
unsigned long numbytes = wav->dat.size;
unsigned long numsamps = numbytes*8 / m_wfx.wBitsPerSample;
HRESULT hr = AVIStreamWrite(m_pAudioStream,m_lAudioSample,numsamps,wav->dat.data,numbytes,0,NULL,NULL);
if (buf!=0) delete[] buf;
if (hr!=AVIERR_OK) {
MessageBox(NULL,"AVIERR_OK","ERROR",MB_OK);
return hr;
}
m_lAudioSample+=numsamps;
MessageBox(NULL,"AVIS_OK","S_OK",MB_OK);
return S_OK;
}
GeneralRe: Record AVI with sound Pin
huutribk200115-May-06 20:26
huutribk200115-May-06 20:26 
GeneralRe: Record AVI with sound Pin
normanS15-May-06 23:57
normanS15-May-06 23:57 
GeneralRe: Record AVI with sound Pin
huutribk200116-May-06 0:02
huutribk200116-May-06 0:02 
GeneralRe: Record AVI with sound Pin
normanS16-May-06 0:22
normanS16-May-06 0:22 
GeneralRe: Record AVI with sound Pin
huutribk200116-May-06 16:51
huutribk200116-May-06 16:51 
GeneralRe: Record AVI with sound Pin
normanS16-May-06 19:23
normanS16-May-06 19:23 
QuestionHelp mapping & updating xml files data to tables of MS Access database through vc++ Pin
nrj2315-May-06 17:37
nrj2315-May-06 17:37 
AnswerRe: Help mapping & updating xml files data to tables of MS Access database through vc++ Pin
_AnsHUMAN_ 15-May-06 17:46
_AnsHUMAN_ 15-May-06 17:46 
GeneralRe: Help mapping & updating xml files data to tables of MS Access database through vc++ Pin
nrj2315-May-06 18:32
nrj2315-May-06 18:32 
GeneralRe: Help mapping & updating xml files data to tables of MS Access database through vc++ Pin
nrj2316-May-06 20:25
nrj2316-May-06 20:25 
GeneralRe: Help mapping & updating xml files data to tables of MS Access database through vc++ Pin
_AnsHUMAN_ 16-May-06 20:36
_AnsHUMAN_ 16-May-06 20:36 
GeneralRe: Help mapping & updating xml files data to tables of MS Access database through vc++ Pin
nrj2316-May-06 21:00
nrj2316-May-06 21:00 
GeneralRe: Help mapping & updating xml files data to tables of MS Access database through vc++ Pin
_AnsHUMAN_ 16-May-06 21:06
_AnsHUMAN_ 16-May-06 21:06 
AnswerRe: Help mapping & updating xml files data to tables of MS Access database through vc++ Pin
nrj2315-May-06 20:43
nrj2315-May-06 20:43 
Questionhow to create a transparent Edit control on a CWnd object, while not a CDialog object? Pin
samfromcn15-May-06 15:55
samfromcn15-May-06 15:55 
AnswerRe: how to create a transparent Edit control on a CWnd object, while not a CDialog object? Pin
NiceNaidu15-May-06 18:41
NiceNaidu15-May-06 18:41 
GeneralRe: how to create a transparent Edit control on a CWnd object, while not a CDialog object? Pin
samfromcn16-May-06 16:25
samfromcn16-May-06 16:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.