[PR] avformat/dashdec: don't stop at the first input EOF (PR #23893)

James Almer via ffmpeg-devel <[email protected]> Fri, 24 Jul 2026 14:33:46 -0000
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178490362712.59.17375519733377053128@29965ddac10e>
PR #23893 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23893
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23893.patch

The current logic would stop demuxing the entire manifest once the first Representation returned EOF, which could result in plenty of packets from other Representations being lost.


>From 8b3208db8d297d83467334006fa24a96d4144c25 Mon Sep 17 00:00:00 2001
From: James Almer <[email protected]>
Date: Fri, 24 Jul 2026 11:30:57 -0300
Subject: [PATCH] avformat/dashdec: don't stop at the first input EOF

The current logic would stop demuxing the entire manifest once the first Representation
returned EOF, which could result in plenty of packets from other Representations being
lost.

Signed-off-by: James Almer <[email protected]>
---
 libavformat/dashdec.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index ba49677a09..d4a05ace7e 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -2380,7 +2380,7 @@ static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     if (!cur) {
-        return AVERROR_INVALIDDATA;
+        return AVERROR_EOF;
     }
     while (!ff_check_interrupt(c->interrupt_callback) && !ret) {
         ret = av_read_frame(cur->ctx, pkt);
@@ -2396,9 +2396,17 @@ static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
             cur->is_restart_needed = 0;
             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);
+            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;
         }
     }
-    return AVERROR_EOF;
+    return ret;
 }
 
 static int dash_close(AVFormatContext *s)
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]