Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTypedefs Pin
koumodaki15-May-06 23:49
koumodaki15-May-06 23:49 
AnswerRe: Typedefs Pin
Cedric Moonen15-May-06 23:55
Cedric Moonen15-May-06 23:55 
AnswerRe: Typedefs Pin
Stephen Hewitt16-May-06 0:06
Stephen Hewitt16-May-06 0:06 
AnswerRe: Typedefs Pin
ThatsAlok16-May-06 0:08
ThatsAlok16-May-06 0:08 
AnswerRe: Typedefs Pin
Laxman Auti16-May-06 1:33
Laxman Auti16-May-06 1:33 
AnswerRe: Typedefs Pin
koumodaki16-May-06 2:02
koumodaki16-May-06 2:02 
GeneralRe: Typedefs Pin
Stephen Hewitt16-May-06 14:51
Stephen Hewitt16-May-06 14:51 
QuestionHow to record avi with sound from BITMAP Pin
huutribk200115-May-06 23:19
huutribk200115-May-06 23:19 
Hi,
I have developed the program that record a AVIs and the program that record sound to wav file,
Now I want to develop a other program to merge AVIs and wav file to avi with sound,


Have anybody know how to do this? Please help me!

The follow are some my code:
The separate module that record just avis (no sound) worked well
//Add Frame to avi file

bool CAVIUtil::AddFrame(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);
}

The record wav and record avi run with two other thread, when they finished I just add the follow code to add them togetther, but it can not play(seem to wrong format).

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_lSample,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_lSample+=numsamps;
MessageBox(NULL,"AVIS_OK","S_OK",MB_OK);
return S_OK;
}

Please help me soon if you can
Thank in advance


QuestionATL Service CreateProcess Pin
Oldnavigator15-May-06 23:16
Oldnavigator15-May-06 23:16 
QuestionTCP and Thread problem Pin
Just Baballa15-May-06 22:57
Just Baballa15-May-06 22:57 
AnswerRe: TCP and Thread problem Pin
Cedric Moonen15-May-06 23:02
Cedric Moonen15-May-06 23:02 
GeneralRe: TCP and Thread problem Pin
Just Baballa15-May-06 23:30
Just Baballa15-May-06 23:30 
QuestionRemote Debugging Pin
Raj241115-May-06 22:51
Raj241115-May-06 22:51 
Questioncalculate the size of HBITMAP Pin
anilksingh15-May-06 21:55
anilksingh15-May-06 21:55 
AnswerRe: calculate the size of HBITMAP Pin
Hamid_RT15-May-06 22:30
Hamid_RT15-May-06 22:30 
AnswerRe: calculate the size of HBITMAP Pin
Jitendra gangwar15-May-06 22:54
Jitendra gangwar15-May-06 22:54 
AnswerRe: calculate the size of HBITMAP Pin
Sarath C16-May-06 1:58
Sarath C16-May-06 1:58 
AnswerRe: calculate the size of HBITMAP Pin
David Crow16-May-06 3:55
David Crow16-May-06 3:55 
QuestionReading and Writing to a file at the same time Pin
waxie15-May-06 21:24
waxie15-May-06 21:24 
AnswerRe: Reading and Writing to a file at the same time Pin
Naveen15-May-06 21:50
Naveen15-May-06 21:50 
GeneralRe: Reading and Writing to a file at the same time Pin
waxie15-May-06 21:51
waxie15-May-06 21:51 
GeneralRe: Reading and Writing to a file at the same time Pin
Naveen15-May-06 21:57
Naveen15-May-06 21:57 
GeneralRe: Reading and Writing to a file at the same time Pin
waxie15-May-06 22:27
waxie15-May-06 22:27 
GeneralRe: Reading and Writing to a file at the same time Pin
kakan15-May-06 22:35
professionalkakan15-May-06 22:35 
GeneralRe: Reading and Writing to a file at the same time Pin
waxie15-May-06 22:46
waxie15-May-06 22:46 

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.