[FFmpeg-devel] understanding usage of av_compare_ts() in avformat/hlsenc

Anssi Hannula anssi.hannula at iki.fi
Thu Jul 10 00:41:56 CEST 2014


08.07.2014 13:19, Nicolas Martyanoff kirjoitti:
> Hi,

Hi,

> I am currently working on improving the hlsenc muxer to support byteranges
> (HLS version 4), and it is starting to work :) But there is a line that really
> puzzles me:
> 
> 
>     if (can_split && av_compare_ts(pkt->pts - hls->start_pts, st->time_base,
>                                            end_pts, AV_TIME_BASE_Q) >= 0) {
> 
>     // libavformat/hlsenc.c 282
> 
> 
> Afaik, av_compare_ts() compares two presentation timestamps with potentially
> different time bases, and returns a value indicating if the first timestamp is
> larger (i.e. more recent) than the second one.
> 
> However in this code, the first argument is the difference between two
> presentation timestamp, i.e. a time length. I do not get how comparing a time
> length and a presentation timestamp makes any kind of sense.
> 
> Does anyone know what I am missing here ?

I guess you may have gotten this already, but anyway:

The end_pts is actually a time length as well, not an actual PTS, since
it is just (number_of_segments * length_of_segment).


> Thank you in advance.

-- 
Anssi Hannula



More information about the ffmpeg-devel mailing list