Repository navigation
Count an MP4 edit list's discarded pre-roll out of the frame count (task #54) - #213
Open
StuartCameronCode wants to merge 4 commits into
Open
StuartCameronCode wants to merge 4 commits into
StuartCameronCode wants to merge 4 commits into
Conversation
…del's frame count (task #54) nb_frames of an MP4/MOV is the sample table's count, and an edit list's pre-roll (kept for decoding, marked discard, never output) is in it: small_clip.mp4 stores 3154 and decodes 3151, so the app's timeline ran 3 frames long and an untrimmed encode ended on 3 copies of the last picture. When the head probe (now with flags) or an MP4/MOV's tail probe sees a discarded packet, the count is the last kept picture's grid slot + 1. Not 'packets not discarded': a stream-copy cut leaves timestamp holes the grid fills (edit_list_bframes.mp4: 146 stored, 125 kept, 128 slots). A job without a count takes the model's again (apply_source_model); -count_frames stays only for a job with no model or a raw reset TS/PS the app did not prepare (counts_by_decoding). Audio Restoration's drift reads the whole source's length from the model too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e the model's count (task #54) The source grid suite checks small_clip.mp4 and edit_list_bframes.mp4 at their last frames, and jobs sent without a count encode every slot. DVB-T to AVI without a count now stores the grid's 128 slots (126 pictures, two repeated at field-coding gaps), as an app job always did; small_clip copied into AVI ends on the source's last pictures; v210 compares with the model's 79, not -count_frames' 75. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ll out (task #54) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fault
For an MP4/MOV, the source model's frame count used
nb_frames. That number includes the pre-roll packets an edit list keeps for decoding but marks as discarded.small_clip.mp4stores 3154 frames but decodes 3151. So the app's timeline offered 3 frames that don't exist, and an untrimmed encode ended on 3 copies of the last picture.The fix
source_model::frame_count, rule 2a: when the demuxer marks video packets as discarded (Dinpacket=flags), the count is the last kept picture's grid slot + 1.flags, or by a tail probe over the last 3 s. The tail probe runs alongside the other probes, for any MP4/MOV that stores a count.edit_list_bframes.mp4is a stream-copy cut that stores 146 frames and keeps 125, but has gaps in its timestamps that the grid fills, so it decodes to 128.apply_source_model).-count_framesis kept only for a job with no model, or for a raw MPEG-PS/TS whose timestamps reset and that wasn't continuity-checked (counts_by_decoding). Audio Restoration's drift measurement on a trimmed job also uses the model's count.Cost
On a 2-hour MP4, the tail probe takes 0.05 s and the whole
--probe-source0.13 s.-count_framestakes 20.7 s on the same file. All four counts agree. Every other committed fixture keeps its count.Known limit
An edit list whose discarded packets are only in the middle of the file (a multi-entry edit list) still counts
nb_frames; nothing cheap detects that case.Tests
discards_from_probe,apply_source_modelfor every trim shape, andcounts_by_decoding.integration_source_grid_test.dartaddssmall_clip.mp4andedit_list_bframes.mp4, plus a group checking that a job without a count encodes every slot.integration_video_start_offset_test.dart: the DVB-T AVI test now expects 128, and the small_clip AVI test checks the output ends on the source's last pictures.cargo test: all pass except the subtitle test, which needs the Whisper add-on (not installed).late_video.mkvto AVI with Convert, failed once and then passed 3 times out of 3. That is the known intermittent fault, task Version 0.9.11 Not Deinterlacing #58.Report:
docs/reports/task-54-edit-list-count. Task #59 was filed for an issue with trim end points found along the way.🤖 Generated with Claude Code