Skip to content

Fix concat-demuxer seek failure on multi-segment sources - #424

Closed
RufanMelfor wants to merge 1 commit into
reco-project:mainfrom
RufanMelfor:fix/concat-multisegment-seek
Closed

Fix concat-demuxer seek failure on multi-segment sources#424
RufanMelfor wants to merge 1 commit into
reco-project:mainfrom
RufanMelfor:fix/concat-multisegment-seek

Conversation

@RufanMelfor

Copy link
Copy Markdown
Contributor

Scrubbing/seeking to any timestamp in a chained multi-segment recording
(e.g. a camera's auto-split 4GB files) failed with "Invalid seek" for both
cameras. Root-caused directly against libavformat: without a duration
hint per file entry, FFmpeg's concat demuxer can't build a seekable
index across segments and reports the whole chain as non-seekable —
avformat_seek_file returns AVERROR(ESPIPE) for any target, even one
inside the first segment. Single-file sources were unaffected, which is
why this only surfaces once a user selects multiple segments per side.

Fix: probe each segment's duration (format-only open, no decoder/hw setup)
when building the concat manifest, and emit a duration <secs> line next
to each file entry. One-time cost at chain-open time, not per-seek or
per-frame.

Verified: fmt --check/build/cargo test -p reco-io clean against
current origin/main.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

All contributors have signed the CLA. Thank you!
Posted by the CLA Assistant Lite bot.

Scrubbing/seeking to any timestamp (e.g. entering a frame number) in a
chained multi-segment recording (DJI's auto-split 4GB files) failed with
"FFmpeg: Invalid seek" for both cameras. Root cause confirmed directly
against libavformat (not just inferred): without a `duration` hint per
`file` entry, FFmpeg's concat demuxer can't build a seekable index across
segments and reports the whole chain as non-seekable - `avformat_seek_file`
returns AVERROR(ESPIPE) for *any* target, even one within the first
segment. Single-file sources were unaffected, which is why this only
showed up once a user picked multiple segments per side.

Fix: probe each segment's duration (format-only open, no decoder/hw setup)
when building the concat manifest and emit a `duration <secs>` line next
to each `file` entry. One-time cost at chain-open time, not per-seek or
per-frame.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@RufanMelfor

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@mohamedtahaguelzim

Copy link
Copy Markdown
Contributor

Hi, I will close this PR as it is a duplicate of a fix that landed in #329. Your fix was similar to what I merged. Thanks again. I already merged some of your other PRs, and will look into and hopefully merge the others too :)

@github-project-automation github-project-automation Bot moved this from In review to Done (Released) in Project Backlog Jul 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Done (Released)

Development

Successfully merging this pull request may close these issues.

2 participants