[Libav-user] latency of mpegts handling in libavformat

Alex Cohn alexcohn at netvision.net.il
Wed Jul 27 18:08:16 CEST 2011


On Wed, Jul 27, 2011 at 17:23, כרמל מגן <carmel.work at gmail.com> wrote:

>  I am sending and receiving h.264 video on mpeg2-ts over udp.
> 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 *does
> not return* with frame X-2 until frame X starts arriving.
>

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?

And I still suspect that your sender used msx_b_frames == 2 when it
initialized the AVCodecContext* encoderContext for avcodec_open().

Cheers,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110727/c47dc3b6/attachment.html>


More information about the Libav-user mailing list