AVIFreak

I am trying to combine an audio stream from a microphone and a video capture stream in the AVI Mux filter to create an AVI file. The audio stream is from the SoundMAX Digital Audio card I have in my PC and the video comes from a modified push source filter that captures desktop screenshots. The video format is RGB_24 and the audio format is PCM. My graph is as follows:

Video:
Push Source -> Smart Tee -> AVI Mux -> File Writer

Audio
Sound Card -> Smart Tee -> AVI Mux -> File Writer

The audio is consistently out of sync with the video by 2-3 seconds...I'm kind of a novice at this so I'm confused on how to fix it. Please, any suggestions

AVIFreak


Re: DirectShow Development Audio and video streams out of sync in GraphEdit

Michel Roujansky

How do you timestamp your video samples in the source flter

Did you try setting the interleaving mode on the avi mux






Re: DirectShow Development Audio and video streams out of sync in GraphEdit

AVIFreak

The interleaving on the AVI mux is set to FULL right now. I had it on NONE and the out-of-sync was even worse.

I have a code snippet below that shows the timestamping:

// Set the timestamps that will govern playback frame rate.
// If this file is getting written out as an AVI,
// then you'll also need to configure the AVI Mux filter to
// set the Average Time Per Frame for the AVI Header.
// The current time is the sample's start.
REFERENCE_TIME rtStart = m_iFrameNumber * m_rtFrameLength;

pSample->SetTime(&rtStart, &rtStop);
m_iFramNumber++;

// Set TRUE on every sample for uncompressed frames
pSample->SetSyncPoint(TRUE);

return S_OK;

Thanks.




Re: DirectShow Development Audio and video streams out of sync in GraphEdit

AVIFreak

Oops, forgot a line.

REFERENCE_TIME rtStart = m_iFrameNumber * m_rtFrameLength;
REFERENCE_TIME rtStop = rtStart + m_rtFrameLength;

pSample->SetTime(&rtStart, &rtStop);
m_iFramNumber++;

// Set TRUE on every sample for uncompressed frames
pSample->SetSyncPoint(TRUE);

return S_OK;





Re: DirectShow Development Audio and video streams out of sync in GraphEdit

AVIFreak

bump




Re: DirectShow Development Audio and video streams out of sync in GraphEdit

Trevor Lowing

Did you have any luck syncing the streams I'm tryign to do something similar.





Re: DirectShow Development Audio and video streams out of sync in GraphEdit

Michel Roujansky

If the lateness of the audio is constant, you could try to "delay" the video by increasing the timestamps by the amount of this lateness, something like

Code Snippet

tStart = (m_frameNumber * m_frameLength) + 3*UNITS; // 3 seconds delay