You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
media: include the final AAC transport packet in duration - #4033
The shared MPEG route used the last audio PTS as the clip end. ADTS packet positions already use the rebased native audio clock, including gaps. For audio-only transport streams with a fixed AAC ADTS packet length established during open, include the end of that span in the duration calculation. The change reuses the existing sample index and reads no additional packets.
adts_transport_duration_includes_the_final_packet generates contiguous and gapped streams with a nonzero PTS origin. The old probe ended the contiguous clip at 2,048 samples. It now reports 3,072 samples, includes the later gap in the gapped case, and the final packet decodes to audible samples.
Verification
cargo test --locked -p effectcraft-media passed on Windows after rebasing onto 775b157e, with 206 unit and 75 integration tests reported passing and one existing ignored test. FFmpeg-dependent cases skipped because FFmpeg was unavailable on PATH.
Formatting, diff check, and strict all-target Clippy passed.
No actionable comments were generated in the recent review.
Walkthrough
Audio track entries now store an optional fixed packet sample count. For audio-only MPEG-TS sources, finish_container_source extends duration through the final ADTS AAC packet. A test checks playback and reported duration for two possible final-packet timestamps.
Changes: ADTS AAC duration handling
Layer / File(s)
Summary
Track packet metadata and end-time calculation crates/media/src/craft_source.rs
Audio track entries store optional fixed packet sample counts. The ADTS AAC end-time calculation uses packet start times and the fixed sample count. The MXF PCM initializer sets the field to None.
MPEG-TS duration extension and validation crates/media/src/craft_source.rs
Audio-only MPEG-TS sources extend duration through the latest ADTS AAC track end. A test checks playback and reported duration for two possible final-packet timestamps.
This change makes the reported duration of audio-only AAC transport streams include the final packet's playable samples. Other sources keep their existing duration calculation. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "media: include the final AAC transport packet in duration" matches the main change. The summary says finish_container_source now extends duration for audio-only MPEG-TS ADTS AAC sources to …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "media: include the final AAC transport packet in duration" matches the main change. The summary says finish_container_source now extends duration for audio-only MPEG-TS ADTS AAC sources to the end of the final packet, and the objectives describe the same fix. The title is specific and concise, and it names the affected component (media) and the change.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 775b157 and 069cc9d.
Files selected for processing: 1
crates/media/src/craft_source.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
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
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.
Audio-only AAC transport streams now include the final packet’s playable samples in the reported clip duration.
Part of storytold/craft-libs#778 and storytold/craft-libs#781. Scoped claim
The shared MPEG route used the last audio PTS as the clip end. ADTS packet positions already use the rebased native audio clock, including gaps. For audio-only transport streams with a fixed AAC ADTS packet length established during open, include the end of that span in the duration calculation. The change reuses the existing sample index and reads no additional packets.
adts_transport_duration_includes_the_final_packetgenerates contiguous and gapped streams with a nonzero PTS origin. The old probe ended the contiguous clip at 2,048 samples. It now reports 3,072 samples, includes the later gap in the gapped case, and the final packet decodes to audible samples.Verification
cargo test --locked -p effectcraft-mediapassed on Windows after rebasing onto775b157e, with 206 unit and 75 integration tests reported passing and one existing ignored test. FFmpeg-dependent cases skipped because FFmpeg was unavailable on PATH.Summary by CodeRabbit