Skip to content

media: derive audio-only AVI PCM duration from indexed blocks - #4042

Merged
dylanmtaylor merged 2 commits into
storytold:mainfrom
Terra854:fix/avi-pcm-indexed-duration
Nov 21, 2026
Merged

dylanmtaylor merged 2 commits into
storytold:mainfrom
Terra854:fix/avi-pcm-indexed-duration

Conversation

@Terra854

@Terra854 Terra854 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

EffectCraft now reports the duration of all indexed PCM blocks in an audio-only AVI. The reader already uses complete blocks to place PCM chunks during playback. Using the same count for the probe prevents a stale declared length from hiding decodable samples or extending the clip into silence.

Part of storytold/craft-libs#778 and storytold/craft-libs#781. Scoped claim

The regression generates two 48 kHz PCM chunks containing 7 and 13 samples. Before the fix the same file reported 1, 20, or 200 samples, depending on the header. It now reports 20 samples for each header and reads the last sample followed by silence. The change combines cleanly with #4037 and is based on main after #4030.

  • Windows cargo test --locked -p effectcraft-media passed with 210 unit and 75 integration tests, plus one ignored unit test. Optional FFmpeg-dependent cases skipped because FFmpeg was unavailable on PATH.
  • Formatting, the diff check, and strict all-target Clippy passed.

Summary by CodeRabbit

  • Bug Fixes
    • Audio-only AVI files using indexed PCM chunks now report duration based on the complete indexed chunks, even when the declared stream length differs. Playback of samples near the end of these files now follows the indexed chunk data. Other audio tracks continue to use the declared stream length.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Audio-only AVI duration now uses indexed PCM chunks when sample_size is positive. Other audio tracks continue to use the declared stream length. A test checks duration and final-sample playback across different declared lengths.

Changes: Audio-only AVI PCM duration

Layer / File(s) Summary
Calculate and validate indexed PCM duration
crates/media/src/craft_source.rs
For PCM streams with a positive sample size, duration uses the complete sample blocks in indexed chunks. The test varies the declared stream length and checks duration and final-sample playback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • Issue 1701 — Tracks broad AVI import support, including stream timing. This change covers audio-only AVI PCM duration based on indexed blocks; it does not complete the broader issue.

Suggested reviewers: dylanmtaylor, fredapps

Merge Risk: Minimal · up to 10458

Audio-only AVI files with PCM audio now report the duration of all indexed sample blocks, which matches how playback places the data. Other formats are unaffected, and a regression test covers the new behavior. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: audio-only AVI PCM duration is now derived from indexed blocks. The raw summary confirms that PCM duration with sample_size > 0 uses the sum of complete indexed chunk …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: audio-only AVI PCM duration is now derived from indexed blocks. The raw summary confirms that PCM duration with sample_size > 0 uses the sum of complete indexed chunk blocks, and the objectives describe the same goal. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution timed out
Clippy (1.99.1) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

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.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 364ba64 and 1045884.

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.

…uration

# Conflicts:
#	crates/media/src/craft_source.rs
@dylanmtaylor
dylanmtaylor merged commit ea64796 into storytold:main Nov 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants