[Live-devel] Regarding the audio and video sync
梦幻工作室
fantasyvideo at 126.com
Mon Sep 17 00:27:46 PDT 2012
My session has one video and audio stream.
In the audio stream’s doGetNextFrame(), I set the fPresentationTime like
this:
void AudioFrameSource::doGetNextFrame() {
CamerManager::GetInstance()->GetAudioFrame(“test”,(char*)fTo,fMaxSize,
&fFrameSize,&fNumTruncatedBytes);
if (fIsFirstPresentationTime) {
CameraManager::GetInstance()->GetTimeScale(&m_timescale);
fIsFirstPresentationTime = False; // from now on
}
fPresentationTime = m_timescale;
fDurationInMicroseconds = 5000; // because 40 samples at 8000
samples-per-second have a duration of 5 ms (== 5000 us)
// Compute the next presentation time (i.e., to be used on the next call
to "doGetNextFrame()"):
m_timescale.tv_usec += fDurationInMicroseconds;
if (m_timescale.tv_usec > 1000000) {
++m_timescale.tv_sec;
m_timescale.tv_usec -= 1000000;
}
}
In the videoFramesource I set the same timestamp,
void VideoFrameSource::doGetNextFrame() {
CamerManager::GetInstance()->GetVideoFrame(“test”,(char*)fTo,fMaxSize,
&fFrameSize,&fNumTruncatedBytes);
if (fIsFirstPresentationTime) {
CameraManager::GetInstance()->GetTimeScale(&m_timescale);
fIsFirstPresentationTime = False; // from now on
}
fPresentationTime = m_timescale;
fDurationInMicroseconds = 5000; // because 40 samples at 8000
samples-per-second have a duration of 5 ms (== 5000 us)
// Compute the next presentation time (i.e., to be used on the next call
to "doGetNextFrame()"):
m_timescale.tv_usec += fDurationInMicroseconds;
if (m_timescale.tv_usec > 1000000) {
++m_timescale.tv_sec;
m_timescale.tv_usec -= 1000000;
}
}
But unfortunately, I use vlc to access it, it can’t work correctly. If
video is appear, then audio disappears. Otherwise, audio appears, video
disappears.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120917/e31cbc44/attachment.html>
More information about the live-devel
mailing list