Commit 48472ef18b for ffmpeg

commit 48472ef18bfc9c165c83154069c902504fb92907
Author: Kacper Michajłow <kasper93@gmail.com>
Date:   Tue Oct 27 06:04:08 2026 +0100

    avformat/dashdec: fix seeking after EOF

    Since d9da090b1d, a representation that returns EOF is closed and its
    streams are set to AVDISCARD_ALL, so that recheck_discard_flags() does
    not reopen it. dash_read_seek() only does a dry run for representations
    that are not open, so after a seek they stay closed and return no
    packets, and playback cannot continue after a seek once the end was
    read. Mark the representation as being at EOF instead, skip it when
    picking the next packet, clear the mark when it is seeked or closed, and
    leave the discard flags to the caller.

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

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 85fb709c26..4635df4cb2 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -125,6 +125,7 @@ struct representation {
     uint32_t init_sec_buf_read_offset;
     int64_t cur_timestamp;
     int is_restart_needed;
+    int eof;
 };

 typedef struct DASHContext {
@@ -2035,6 +2036,7 @@ static void close_demux_for_component(struct representation *pls)
     memset(&pls->pb, 0x00, sizeof(pls->pb));
     pls->ctx->pb = NULL;
     avformat_close_input(&pls->ctx);
+    pls->eof = 0;
 }

 static int reopen_demux_for_component(AVFormatContext *s, struct representation *pls)
@@ -2461,7 +2463,7 @@ static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)

     for (i = 0; i < c->n_videos; i++) {
         rep = c->videos[i];
-        if (!rep->ctx)
+        if (!rep->ctx || rep->eof)
             continue;
         if (!cur || rep->cur_timestamp < mints) {
             cur = rep;
@@ -2470,7 +2472,7 @@ static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
     }
     for (i = 0; i < c->n_audios; i++) {
         rep = c->audios[i];
-        if (!rep->ctx)
+        if (!rep->ctx || rep->eof)
             continue;
         if (!cur || rep->cur_timestamp < mints) {
             cur = rep;
@@ -2480,7 +2482,7 @@ static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)

     for (i = 0; i < c->n_subtitles; i++) {
         rep = c->subtitles[i];
-        if (!rep->ctx)
+        if (!rep->ctx || rep->eof)
             continue;
         if (!cur || rep->cur_timestamp < mints) {
             cur = rep;
@@ -2506,12 +2508,8 @@ static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
             ff_format_io_close(cur->parent, &cur->input);
             ret = reopen_demux_for_component(s, cur);
         } else if (ret == AVERROR_EOF) {
-            close_demux_for_component(cur);
-            ff_format_io_close(cur->parent, &cur->input);
+            cur->eof = 1;
             av_log(s, AV_LOG_DEBUG, "EOF on stream_index %d\n", cur->stream_index);
-            // prevent recheck_discard_flags() from re-enabling the component
-            for (int i = 0; i < cur->nb_assoc_stream; i++)
-                cur->assoc_stream[i]->discard = AVDISCARD_ALL;
             return FFERROR_REDO;
         }
     }
@@ -2543,6 +2541,7 @@ static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t see
     if (pls->n_fragments == 1) {
         pls->cur_timestamp = 0;
         pls->cur_seg_offset = 0;
+        pls->eof = 0;
         if (dry_run)
             return 0;
         ff_read_frame_flush(pls->ctx);