]> git.sesse.net Git - ffmpeg/commitdiff
avformat/dashdec: Also fetch final partial segment
authorMatt Robinson <git@nerdoftheherd.com>
Mon, 5 Apr 2021 17:45:04 +0000 (18:45 +0100)
committerSteven Liu <liuqi05@kuaishou.com>
Wed, 14 Apr 2021 07:28:04 +0000 (15:28 +0800)
Currently, the DASH demuxer omits the final segment for a non-live
stream (using SegmentTemplate) if it is shorter than the other segments.

Correct calc_max_seg_no to round up when calulating the number of
segments instead of rounding down to resolve this issue.

Signed-off-by: Matt Robinson <git@nerdoftheherd.com>
libavformat/dashdec.c

index 6f3f28dcc7b58fb81c9d39f2dd6f0d4dd2bad1e8..73effd85dbe57846f8ac7950c03dce5ea9190a02 100644 (file)
@@ -1445,7 +1445,7 @@ static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c)
     } else if (c->is_live && pls->fragment_duration) {
         num = pls->first_seq_no + (((get_current_time_in_sec() - c->availability_start_time)) * pls->fragment_timescale)  / pls->fragment_duration;
     } else if (pls->fragment_duration) {
-        num = pls->first_seq_no + (c->media_presentation_duration * pls->fragment_timescale) / pls->fragment_duration;
+        num = pls->first_seq_no + av_rescale_rnd(1, c->media_presentation_duration * pls->fragment_timescale, pls->fragment_duration, AV_ROUND_UP);
     }
 
     return num;