<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="">Right now, I have problem make them stream out together, it seems audio will hang the video immediately when connect the RTSP server using VLC</div></div></div></div></blockquote><div><br class=""></div>I suggest that you first use our “openRTSP” RTSP client application <<a href="http://www.live555.com/openRTSP/" class="">http://www.live555.com/openRTSP/</a>> to test receiving both audio and video from your server. Using “openRTSP”, you should see (nonempty) files for both the audio and video stream. (“openRTSP” is a much simpler client application than VLC, because it doesn’t render the incoming media, and doesn’t care whether their presentation times are correct.)</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class="">I doubt the problem that the time stamp for video and audio are not correct, since during playing using VLC, I notice that two different time are shown alternately, for the video, I set the "fPresentationTime" as below: since the frame rate of my H264 video is 30fps, the time for the first video frame is based on the "gettimeofday", then increased based on frame rate </div><div class=""><br class=""></div><div class="">----------</div><div class=""><p class=""><span class=""> </span><span class="">if</span><span class="">( encoder_video_ts.tv_sec == 0 && encoder_video_ts.tv_usec == 0 )</span></p></div></div></div></blockquote><div>Are you certain that this branch is actually getting executed - i.e., that your “encoder_video_ts” variable (both the “tv_sec” and “tv_usec” fields) is actually initialized to 0?</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><p class=""><span class=""> gettimeofday( &encoder_video_ts, </span><span class="">NULL</span><span class=""> ); </span><span class="">//Set the first stream time stamp from wall clock </span></p><p class=""><span class=""> </span><span class="">else</span><span class=""> {</span></p><p class=""><span class=""> </span><span class="">unsigned</span><span class=""> </span><span class="">uSeconds</span><span class=""> = encoder_video_ts.tv_usec + 1000000/30; </span><span class="">//Framerate is 30fps</span></p></div></div></div></blockquote>This is correct *only if* each NAL unit that you deliver is a complete ‘access unit’ - i.e., picture. If, instead, your stream includes PPS and SPS NAL units, and/or ‘slice’ NAL units, then this calculation won’t be correct.</div><div><br class=""></div><div>In any case, I suggest simplifying your code by just setting “fPresentationTime” for *each* of your video NAL units by calling “gettimeofday()” - as you already do for the audio frames.</div><div><br class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><p class=""></p></div><div class="">since audio and video are feeding using two separated thread, is this the correct way to sync the A/V ?</div></div></div></blockquote><div><br class=""></div>Yes, if the “fPresentationTime” values are accurate, *and* aligned with ‘wall clock’ time (i.e., times that would be generated by “gettimeofday()”), then audio and video will get properly synchronized by standards-conforming RTP/RTCP clients (like VLC).</div><br class=""><div apple-content-edited="true" class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Ross Finlayson<br class="">Live Networks, Inc.<br class=""><a href="http://www.live555.com/" class="">http://www.live555.com/</a></span></span>
</div><div class=""><br class="webkit-block-placeholder"></div>
<br class=""></body></html>