<div dir="ltr"><div class="gmail_quote">On Wed, Jul 27, 2011 at 17:23, כרמל מגן <span dir="ltr"><<a href="mailto:carmel.work@gmail.com">carmel.work@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0.8ex; PADDING-LEFT: 1ex; PADDING-RIGHT: 1ex; BORDER-RIGHT: #ccc 1px solid" class="gmail_quote">
<div dir="rtl">
<div style="DIRECTION: ltr">I am sending and receiving h.264 video on mpeg2-ts over udp.</div>
<div style="DIRECTION: ltr">After noticing some lag, I added code that prints a timestamp and framenumber after sending and after av_read_frame returns. when comparing timestamps between frames with the same frame number, there is a ~60 ms delay (when sending 30 fps). Furthermore, if I stop at a breakpoint and delay the sending of frame number X, the timestamp of receiving frame number X-2 corresponds to the time of sending of  X (i.e., the time between receiving frame number X-3 and  frame number X-2 is longer if I delay the sending of X longer). The unavoidable conclusion is that av_read_frame <u>does not return</u> with frame X-2 until frame X starts arriving.</div>
</div></blockquote>
<div> </div>
<div>av_read_frame takes an AVFormatContext* as the first parameter. How did you create this object on the receiver side? Can you post the relevant code snippet?</div>
<div> </div>
<div>And I still suspect that your sender used msx_b_frames == 2 when it initialized the AVCodecContext* encoderContext for avcodec_open().</div>
<div> </div>
<div>Cheers,</div>
<div>Alex</div></div></div>