From: Steinar H. Gunderson Date: Sat, 13 Apr 2019 12:38:14 +0000 (+0200) Subject: Fix an issue where HLS fragments would become too short when pts was low. X-Git-Tag: 1.4.3~5 X-Git-Url: https://git.sesse.net/?p=cubemap;a=commitdiff_plain;h=cb042ee88b5f4cd6e5f55bada4d9d86807f1640b;hp=5ee2e95320160f0d01a9af5cea5c799c3ce1eaa9 Fix an issue where HLS fragments would become too short when pts was low. --- diff --git a/stream.cpp b/stream.cpp index 7ea8a95..2c7c42e 100644 --- a/stream.cpp +++ b/stream.cpp @@ -394,7 +394,7 @@ bool Stream::add_fragment_boundary(size_t byte_position, const RationalPTS &pts) // (RFC 8216 4.3.3.1) and we get closer to the target by doing so. // Note that in particular, this means we'll always extend // as long as we don't exceed the target duration. - double current_duration = fragments[fragments.size() - 1].pts; + double current_duration = pts_double - fragments[fragments.size() - 1].pts; double candidate_duration = pts_double - fragments[fragments.size() - 2].pts; if (lrintf(candidate_duration) <= hls_frag_duration && fabs(candidate_duration - hls_frag_duration) < fabs(current_duration - hls_frag_duration)) {