[libav-api] problem with RTP and real time

Luca Barbato lu_zero at gentoo.org
Thu May 19 10:49:09 CEST 2011

On 5/18/11 4:27 PM, i.lourtet at gmail.com wrote:
> Hello,
> thank you lucas for your answer.
>> On 5/18/11 11:07 AM, Irwin Lourtet wrote:
>>> Hello,
>>> I am developping a program which allows to send a mpeg-ts over rtp
>>> stream. I would like to know if libav has an option to send packet over
>>> rtp at the time it must be displayed. Because now I read packet and I
>>> send them when they are ready, for example I send a  55s video in 30s.
>>> So I would like to send this video in 55s. If I am not enough clear I
>>> would be please to give you more details.
>> the -re option implemented in ffmpeg.c should give you guidance in this
>> regard I guess.
> I found in ffmpeg.c how they implement the -re option. the code is the
> following :
> int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE);
> int64_t now = av_gettime() - ist->start;
> if (pts>  now)
> 	usleep(pts - now);

usleep takes microseconds as argument so you rescale the pts to be in 
that time unit.


More information about the libav-api mailing list