Commit 44178a5361 for ffmpeg
commit 44178a53618ee33c2931b54b870ebc4e444efd6a
Author: Matthew Crossley <Matthew.Crossley@thomsonreuters.com>
Date: Tue Nov 10 15:30:35 2026 +0000
avformat/dashdec: keep timeline position in ticks on manifest refresh
refresh_manifest() converted the current segment start time to whole seconds
by dividing by the timescale, then multiplied it back which loses fractional
seconds. Non-whole segment durations could look up an earlier segment than
the one being read. On a live manifest this can replay the first segment
indefinitely.
Drop the extra arithmetic and keep the position in timescale ticks.
Signed-off-by: Matthew Crossley <Matthew.Crossley@thomsonreuters.com>
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index db5a09e386..f6fa1ca511 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1638,9 +1638,9 @@ static int refresh_manifest(AVFormatContext *s)
struct representation *ccur_video = c->videos[i];
if (cur_video->timelines && cur_video->fragment_timescale > 0) {
// calc current time
- int64_t currentTime = get_segment_start_time_based_on_timeline(cur_video, cur_video->cur_seq_no) / cur_video->fragment_timescale;
+ int64_t currentTime = get_segment_start_time_based_on_timeline(cur_video, cur_video->cur_seq_no);
// update segments
- ccur_video->cur_seq_no = calc_next_seg_no_from_timelines(ccur_video, currentTime * cur_video->fragment_timescale - 1);
+ ccur_video->cur_seq_no = calc_next_seg_no_from_timelines(ccur_video, currentTime - 1);
if (ccur_video->cur_seq_no >= 0) {
move_timelines(ccur_video, cur_video, c);
}
@@ -1654,9 +1654,9 @@ static int refresh_manifest(AVFormatContext *s)
struct representation *ccur_audio = c->audios[i];
if (cur_audio->timelines && cur_audio->fragment_timescale > 0) {
// calc current time
- int64_t currentTime = get_segment_start_time_based_on_timeline(cur_audio, cur_audio->cur_seq_no) / cur_audio->fragment_timescale;
+ int64_t currentTime = get_segment_start_time_based_on_timeline(cur_audio, cur_audio->cur_seq_no);
// update segments
- ccur_audio->cur_seq_no = calc_next_seg_no_from_timelines(ccur_audio, currentTime * cur_audio->fragment_timescale - 1);
+ ccur_audio->cur_seq_no = calc_next_seg_no_from_timelines(ccur_audio, currentTime - 1);
if (ccur_audio->cur_seq_no >= 0) {
move_timelines(ccur_audio, cur_audio, c);
}