Commit 8c690ff8d0 for ffmpeg
commit 8c690ff8d08c04feacd0aa6eb5e3d4c2d08d2c34
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Wed Oct 28 01:33:58 2026 +0100
avformat/dashdec: make single file representations seekable
Expose the input's seekability to the nested demuxer when a
representation is a single complete file in a static presentation. With
several segments it would seek through the fragments of every segment.
An indexed demuxer can reach EOF without reading past the end of the
file. Advance the segment number when av_read_frame() finishes the
current segment.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index ac91fd5ad9..f2525bbe08 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -124,7 +124,6 @@ struct representation {
uint32_t init_sec_data_len;
uint32_t init_sec_buf_read_offset;
int64_t cur_timestamp;
- int is_restart_needed;
int eof;
};
@@ -2021,14 +2020,6 @@ restart:
goto end;
}
ret = read_from_url(v, v->cur_seg, buf, buf_size);
- if (ret > 0)
- goto end;
-
- if (c->is_live || v->cur_seq_no < v->last_seq_no) {
- if (!v->is_restart_needed)
- v->cur_seq_no++;
- v->is_restart_needed = 1;
- }
end:
return ret;
@@ -2106,6 +2097,8 @@ static int reopen_demux_for_component(AVFormatContext *s, struct representation
goto fail;
}
+ if (!c->is_live && pls->n_fragments == 1 && is_whole_file(pls))
+ pls->pb.pub.seekable = pls->input->seekable;
pls->ctx->pb = &pls->pb.pub;
pls->ctx->io_open = nested_io_open;
@@ -2523,10 +2516,11 @@ static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index += cur->stream_index;
return 0;
}
- if (cur->is_restart_needed) {
+ if ((ret == AVERROR_EOF || cur->pb.pub.eof_reached) &&
+ (c->is_live || cur->cur_seq_no < cur->last_seq_no)) {
+ cur->cur_seq_no++;
cur->cur_seg_offset = 0;
cur->init_sec_buf_read_offset = 0;
- 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) {
@@ -2616,7 +2610,6 @@ set_seq_num:
pls->cur_timestamp = 0;
pls->cur_seg_offset = 0;
pls->init_sec_buf_read_offset = 0;
- pls->is_restart_needed = 0;
ret = dry_run ? 0 : reopen_demux_for_component(s, pls);
return ret;