Commit 86fa0d1a6c for ffmpeg

commit 86fa0d1a6c863fc1d7162ef15879c37a50deda15
Author: Kacper Michajłow <kasper93@gmail.com>
Date:   Tue Oct 27 06:04:17 2026 +0100

    avformat/dashdec: fix seeking representations enabled since the last read

    dash_read_seek() only does a dry run for representations that are not
    open. A representation the caller enabled since the last read is not
    open yet, and for a single file the dry run returns without recording
    the target, so the representation was opened at the start of the file
    instead of at the seek target. Seek such representations too, and open
    the demuxer first when there is a single file.

    Signed-off-by: Kacper Michajłow <kasper93@gmail.com>

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 5f5ffa286a..9aacf9b7f7 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -2551,6 +2551,12 @@ static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t see
         pls->eof = 0;
         if (dry_run)
             return 0;
+        if (!pls->ctx) {
+            pls->init_sec_buf_read_offset = 0;
+            ret = reopen_demux_for_component(s, pls);
+            if (ret < 0)
+                return ret;
+        }
         ff_read_frame_flush(pls->ctx);
         return av_seek_frame(pls->ctx, -1, seek_pos_msec * 1000, flags);
     }
@@ -2615,15 +2621,15 @@ static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t timestam
     /* Seek in discarded streams with dry_run=1 to avoid reopening them */
     for (i = 0; i < c->n_videos; i++) {
         if (!ret)
-            ret = dash_seek(s, c->videos[i], seek_pos_msec, flags, !c->videos[i]->ctx);
+            ret = dash_seek(s, c->videos[i], seek_pos_msec, flags, !c->videos[i]->ctx && !representation_needed(c->videos[i]));
     }
     for (i = 0; i < c->n_audios; i++) {
         if (!ret)
-            ret = dash_seek(s, c->audios[i], seek_pos_msec, flags, !c->audios[i]->ctx);
+            ret = dash_seek(s, c->audios[i], seek_pos_msec, flags, !c->audios[i]->ctx && !representation_needed(c->audios[i]));
     }
     for (i = 0; i < c->n_subtitles; i++) {
         if (!ret)
-            ret = dash_seek(s, c->subtitles[i], seek_pos_msec, flags, !c->subtitles[i]->ctx);
+            ret = dash_seek(s, c->subtitles[i], seek_pos_msec, flags, !c->subtitles[i]->ctx && !representation_needed(c->subtitles[i]));
     }

     return ret;