Fix an issue where HLS fragments would become too short when pts was low.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 13 Apr 2019 12:38:14 +0000 (14:38 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 13 Apr 2019 12:38:14 +0000 (14:38 +0200)
stream.cpp

index 7ea8a95..2c7c42e 100644 (file)
@@ -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)) {