mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-31 21:47:02 -06:00
The clip duration came from the media duration (`mdhd`), which runs on the decode timeline. ffmpeg / x264 MP4s with B-frames skip the reorder delay with an edit, so every one imported a frame too long (a 120-frame file became 121 frames, the last a held repeat). A video track delayed by a leading empty edit was a frame short, and its last frame could not be reached. Use the sum of the track's edits (movie timescale, what `tkhd` records) when there is an edit list. Fragmented files, and edit lists that add up to nothing or overflow a Tick, keep the media duration. Tests: a unit test with crafted edit lists (skip, empty edit, hostile sizes) and an ffmpeg oracle test (libx264 with B-frames: 60 frames, was 61). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>