Click here to Skip to main content
15,888,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Creating own Error Report Dialogs Pin
Bob Stanneveld13-Jun-05 11:02
Bob Stanneveld13-Jun-05 11:02 
GeneralRe: Creating own Error Report Dialogs Pin
Jack Puppy13-Jun-05 16:18
Jack Puppy13-Jun-05 16:18 
GeneralAdding Sound to AVI Files Pin
Anonymous13-Jun-05 9:25
Anonymous13-Jun-05 9:25 
GeneralRe: Adding Sound to AVI Files Pin
tom_dx13-Jun-05 13:54
tom_dx13-Jun-05 13:54 
GeneralRe: Adding Sound to AVI Files Pin
Identity Undisclosed13-Jun-05 18:09
Identity Undisclosed13-Jun-05 18:09 
GeneralRe: Adding Sound to AVI Files Pin
normanS15-Jun-05 3:48
normanS15-Jun-05 3:48 
GeneralRe: Adding Sound to AVI Files Pin
normanS13-Jun-05 16:18
normanS13-Jun-05 16:18 
GeneralRe: Adding Sound to AVI Files Pin
normanS13-Jun-05 20:54
normanS13-Jun-05 20:54 
OK, I had a quick look at my code.
This is SDK-based. Why make it easy?

Some background:
The video frames were captured into memory using libraries which came with my frame grabber card, and the audio was captured at the same time, in audio buffers having the same duration as a video frame (40 milliseconds for PAL video.)

Once I have a set of video frames and corresponding audio frames in memory, capture stops and I write an AVI file.

Here is the portion which writes the AVI (including audio stream initialisation but ignoring video stream initialisation):

<br />
uiResult = AVIFileOpen(&pAVIFile,  AVIFileNameEtc.lpstrFile, OF_CREATE, NULL);<br />
if (uiResult != AVIERR_OK)<br />
	exit;<br />
<br />
memset(&AudioStreamInfo, 0, sizeof(AudioStreamInfo));<br />
<br />
// Fill in the header for the audio stream<br />
AudioStreamInfo.fccType = streamtypeAUDIO;<br />
// StreamInfo.fccHandler = 0; // Not used for audio streams<br />
// StreamInfo.dwFlags = 0; // Appears not to be relevant to audio streams<br />
AudioStreamInfo.dwScale = 1; // Documentation confusing - best guess<br />
AudioStreamInfo.dwQuality = -1; // Use handler default quality<br />
AudioStreamInfo.dwRate = 11025; // Audio hard-coded to 11.025 kHz<br />
AudioStreamInfo.dwStart = 0;<br />
<br />
AudioStreamInfo.dwLength = uiLocalNumFramesUsed * uiAudioBufferActualSize;<br />
// Decided on this based on Windows reports of audio length!<br />
// I really don't know what this parameter must be!<br />
<br />
// StreamInfo.dwInitialFrames;  // Used for playback, I guess<br />
AudioStreamInfo.dwSuggestedBufferSize = uiAudioBufferActualSize;<br />
// bytes per block<br />
AudioStreamInfo.dwSampleSize = 2;  // Same as nBlockAlign<br />
// StreamInfo.rcFrame; // not relevant for audio frames<br />
// StreamInfo.dwEditCount; // maintained by stream handler<br />
// StreamInfo.dwFormatChangeCount; // maintained by stream handler<br />
// StreamInfo.szName[64];  // No idea!<br />
<br />
// Create the audio stream;<br />
uiResult = AVIFileCreateStream(pAVIFile, &pAVIAudioStream, &AudioStreamInfo);<br />
if (uiResult != AVIERR_OK)<br />
	exit;<br />
<br />
uiResult = AVIStreamSetFormat(pAVIAudioStream, 0, &AudioFormat,	sizeof(AudioFormat));<br />
if (uiResult != AVIERR_OK)<br />
	exit;<br />
<br />
for (uiCounter = 0; uiCounter < uiNumFramesUsed; uiCounter++)<br />
{<br />
	// generate the video frame to be saved<br />
	// ###################################<br />
	// Some application-specific code here<br />
	// ###################################<br />
<br />
	// write the video frame (data at gpAVIBufBits) to the stream<br />
	uiResult = AVIStreamWrite(pCompressedVideoStream, uiCounter, 1, gpAVIBufBits, 		bitmapForAVIHeader.biSizeImage, 0, NULL, NULL);<br />
	if (uiResult != AVIERR_OK)<br />
		exit;<br />
		<br />
	// Write the corresponding audio block, captured using WaveIn... functions<br />
	uiResult = AVIStreamWrite(pAVIAudioStream, uiCounter, <br />
		1, pAudioDataBlock[(uiCounter],<br />
		uiAudioBufferActualSize, 0, NULL, NULL);<br />
	if (uiResult != AVIERR_OK)<br />
		exit;<br />
}<br />
// Don't forget to close the streams!!!<br />

Generalcustomize key bindings / accelerators Pin
ehh13-Jun-05 8:10
ehh13-Jun-05 8:10 
GeneralRe: customize key bindings / accelerators Pin
Blake Miller13-Jun-05 8:50
Blake Miller13-Jun-05 8:50 
GeneralRe: customize key bindings / accelerators Pin
ehh14-Jun-05 3:55
ehh14-Jun-05 3:55 
GeneralRe: customize key bindings / accelerators Pin
Blake Miller14-Jun-05 5:01
Blake Miller14-Jun-05 5:01 
GeneralRe: customize key bindings / accelerators Pin
ehh14-Jun-05 6:30
ehh14-Jun-05 6:30 
GeneralActiveX Ctrl hanging in MFC code: _AfxFindNextMnem Pin
Ian Bowler13-Jun-05 8:09
Ian Bowler13-Jun-05 8:09 
GeneralExpanding Trees Pin
victorsk13-Jun-05 7:56
victorsk13-Jun-05 7:56 
Generaltoupper macro key Pin
Stober13-Jun-05 6:56
Stober13-Jun-05 6:56 
GeneralRe: toupper macro key Pin
Chris Losinger13-Jun-05 7:06
professionalChris Losinger13-Jun-05 7:06 
GeneralRe: toupper macro key Pin
Stober13-Jun-05 7:24
Stober13-Jun-05 7:24 
GeneralRe: toupper macro key Pin
Chris Losinger13-Jun-05 7:26
professionalChris Losinger13-Jun-05 7:26 
GeneralRe: toupper macro key Pin
Stober13-Jun-05 8:57
Stober13-Jun-05 8:57 
GeneralVery basic question Pin
Opa Knack13-Jun-05 6:49
Opa Knack13-Jun-05 6:49 
GeneralRe: Very basic question Pin
Maximilien13-Jun-05 7:13
Maximilien13-Jun-05 7:13 
GeneralRe: Very basic question Pin
Budric B.13-Jun-05 7:16
Budric B.13-Jun-05 7:16 
GeneralRe: Very basic question Pin
Opa Knack13-Jun-05 7:28
Opa Knack13-Jun-05 7:28 
GeneralRe: Very basic question Pin
Cedric Moonen13-Jun-05 7:37
Cedric Moonen13-Jun-05 7:37 

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.