Click here to Skip to main content
15,891,858 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
I have not checked in detail, but I noticed a difference in dwRate setting - I use the samplesPerSecond value, while you use samplesPerSecond * sampleSize. This will be a problem if you are not using 8-bit samples.

Error checking (using uiResult) removed to save space
Lots of other details removed as well

void SaveAVIFileWithAudio(void)
{
	// This was based on the Microsoft Windows SDK WriteAVI sample
	PAVIFILE pAVIFile = NULL;
	AVISTREAMINFO VideoStreamInfo;
	AVISTREAMINFO AudioStreamInfo;
	PAVISTREAM pAVIVideoStream = NULL;
	PAVISTREAM pCompressedVideoStream = NULL;
	PAVISTREAM pAVIAudioStream = NULL;
	AVICOMPRESSOPTIONS CompressionOptions;

	AVIFileInit(); // Initialises the library or something!

	GetSaveFileName(&AVIFileNameEtc);

	uiResult = AVIFileOpen(&pAVIFile,     // returned file pointer
		   AVIFileNameEtc.lpstrFile,  // file name
		   OF_WRITE | OF_CREATE,
		   NULL);	// use handler determined from file extension....

	memset(&VideoStreamInfo, 0, sizeof(VideoStreamInfo));
	memset(&AudioStreamInfo, 0, sizeof(AudioStreamInfo));

	// Fill in the header for the video stream....
	VideoStreamInfo.fccType = streamtypeVIDEO;
	VideoStreamInfo.fccHandler = mmioFOURCC('m','p','4','2');
	// (And lots more settings - left out to save space in post!)

	uiResult = AVIFileCreateStream(pAVIFile, // file pointer
		 &pAVIVideoStream, // returned stream pointer
		 &VideoStreamInfo); // stream header

	memset(&CompressionOptions, 0, sizeof(CompressionOptions));

	CompressionOptions.fccType = streamtypeVIDEO; 
	CompressionOptions.fccHandler = VideoStreamInfo.fccHandler; 
	// (And lots more settings - left out to save space in post!)

	uiResult = AVIMakeCompressedStream(&pCompressedVideoStream,
		pAVIVideoStream, &CompressionOptions, NULL);

	uiResult = AVIStreamSetFormat(pCompressedVideoStream, 0,
		   &bitmapForAVIHeader,	    // structure containing format
		   bitmapForAVIHeader.biSize);  // structure size

	// Fill in the header for the audio stream
	AudioStreamInfo.fccType = streamtypeAUDIO;
	// StreamInfo.fccHandler = 0; // Not used for audio streams
	// StreamInfo.dwFlags = 0; // Appears not to be relevant to audio streams
	AudioStreamInfo.dwScale = 1; // Documentation confusing - best guess
	AudioStreamInfo.dwQuality = -1; // Use handler default quality
	AudioStreamInfo.dwRate = 11025; // Audio hard-coded to 11.025 kHz
	AudioStreamInfo.dwStart = 0;
	AudioStreamInfo.dwLength = uiLocalNumFramesUsed * 
		uiAudioBufferActualSize;
	// Decided on this based on Windows reports of audio length!
	// I really don't know what this parameter must be!
	// StreamInfo.dwInitialFrames;  // Used for playback, I guess
	AudioStreamInfo.dwSuggestedBufferSize = uiAudioBufferActualSize;
	// bytes per block
	AudioStreamInfo.dwSampleSize = 2;  // Same as nBlockAlign
	// StreamInfo.rcFrame; // not relevant for audio frames
	// StreamInfo.dwEditCount; // maintained by stream handler
	// StreamInfo.dwFormatChangeCount; // maintained by stream handler
	// StreamInfo.szName[64];  // No idea!

	// Create the audio stream;
	uiResult = AVIFileCreateStream(pAVIFile, // file pointer
		 &pAVIAudioStream, // returned stream pointer
		 &AudioStreamInfo); // stream header

	uiResult = AVIStreamSetFormat(pAVIAudioStream, 0,
		   &AudioFormat,	 // structure containing format
		   sizeof(AudioFormat)); // structure size

	for (uiCounter = 0; uiCounter < uiLocalNumFramesUsed; uiCounter++)
	{
		uiResult = AVIStreamWrite(pCompressedVideoStream,
			uiCounter,	// frame counter of this frame
			1,		// number to write
			gpAVIBufBits,  // Pointer to AVIBuffer data
			bitmapForAVIHeader.biSizeImage,	// size of this frame
			0, NULL, NULL);

		// Write the corresponding audio block if appropriate
		uiResult = AVIStreamWrite(pAVIAudioStream,
			uiCounter,	// frame counter of this frame
			1,		// number to write
			pAudioDataBlock[uiLocalIndex],  // Pointer to AVIBuffer data
			uiAudioBufferActualSize,	// size of this frame
			0, NULL, NULL);

	} // end of FOR loop

	AVIStreamRelease(pCompressedVideoStream);

	AVIStreamRelease(pAVIVideoStream);
	AVIStreamRelease(pAVIAudioStream);
	AVIFileRelease(pAVIFile); // Opposite of AVIFileOpen()
	AVIFileExit(); // Opposite of AVIFileInit()
};

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 
QuestionCreate a Window on the Desktop (that replaces the background image, behind the icons) Pin
ghudo15-May-06 15:53
ghudo15-May-06 15:53 
QuestionHTML Help Pin
tigre21515-May-06 14:46
tigre21515-May-06 14:46 
AnswerRe: HTML Help Pin
led mike15-May-06 18:07
led mike15-May-06 18:07 
GeneralRe: HTML Help Pin
NiceNaidu15-May-06 18:46
NiceNaidu15-May-06 18: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.