GeezerVison is showing github.com — fix: trim MiniMax-H3 audio to video duration by losewayy · Pull Request #2350 · leejet/stable-diffusion.cpp
Conversation
losewayy
commented
Nov 14, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
MiniMax-H3 rounds the audio latent count to a 40 Hz grid, so the decoded soundtrack can extend past the last video frame.
Apply the existing Wan2.2 S2V output-audio truncation to MiniMax-H3, using the actual decoded frame count and output frame rate. Only audio exceeding the video duration is trimmed.
Related Issue / Discussion
Fixes #2331.
Additional Information
- Built the Windows Release CPU library and CLI with MSVC.
--help and --list-devices pass.
- Model-free regression executing the audio postprocessing extracted from the source: 13 checks, 7 failures before the fix, all passing after it. Covers H3 at 24 fps, existing S2V behavior at 16 fps, shorter/equal-length audio, and video without decoded audio.
- Checked the actual AVI output with ffprobe and ffmpeg. For 124 frames at 24 fps with 32 kHz stereo audio, the decoded audio decreases from 165600 to 165333 samples per channel; the video remains 124 frames.
Full H3 inference was not run.
Checklist
Summary by CodeRabbit
- Bug Fixes
- Generated audio for Wan2.2 S2V and MiniMax-H3 now ends at the intended video duration when its length exceeds the video. This keeps audio and video playback in sync without shortening audio when the calculated target duration is invalid or longer than the existing audio.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Apply the existing S2V output audio truncation to MiniMax-H3 so rounding the audio latent count cannot extend the returned soundtrack beyond the decoded video duration.
Fixes leejet#2331.
coderabbitai
Bot
commented
Nov 14, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The video pipeline now limits generated audio duration for MiniMax-H3 as well as Wan2.2 S2V. It calculates the desired sample count from the generated video’s frame count and FPS, then truncates the audio when that count is positive and shorter than the current audio.
Changes: Generated audio duration
| Layer / File(s) |
Summary |
Limit generated audio to video duration src/pipeline/video.cpp |
The duration-limiting branch now covers MiniMax-H3 and uses general output-audio wording. The sample-count calculation and truncation conditions remain unchanged. |
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: leejet
Merge Risk: Minimal · up to cc6b5
-
MiniMax-H3 videos will no longer carry extra trailing audio beyond the video duration. The change is small and reuses the existing Wan2.2 S2V trimming behavior, so merge risk is minimal.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: trimming MiniMax-H3 audio to the video duration. It is specific and matches the summary and objectives. It uses the 'fix:' prefix, which is a conventional style and do… |
| Description check |
 |
The description follows the template. It has a Summary that explains the cause (40 Hz audio latent rounding) and the fix (reusing the Wan2.2 S2V truncation with the decoded frame count and output fram… |
| Linked Issues check |
 |
Issue #2331 asks that MiniMax-H3 decoded audio not run past the video duration, with the suggested fix of cutting audio to the video length as the Wan2.2 S2V path does. The whole-PR diff (merge base 0… |
| Out of Scope Changes check |
 |
The whole-PR diff touches only one code block in src/pipeline/video.cpp. It extends the existing audio truncation condition to MiniMax-H3, renames the comment to general output-audio wording, and chan… |
Full details: Title check
-
Explanation
The title names the main change: trimming MiniMax-H3 audio to the video duration. It is specific and matches the summary and objectives. It uses the 'fix:' prefix, which is a conventional style and does not hurt clarity.
Full details: Description check
-
Explanation
The description follows the template. It has a Summary that explains the cause (40 Hz audio latent rounding) and the fix (reusing the Wan2.2 S2V truncation with the decoded frame count and output frame rate). It links the issue with 'Fixes #2331'. Additional Information gives build status, a 13-check regression with before and after results, and ffprobe/ffmpeg sample counts. It notes that full H3 inference was not run. The checklist is marked. The description is complete and specific.
Full details: Linked Issues check
-
Explanation
Issue #2331 asks that MiniMax-H3 decoded audio not run past the video duration, with the suggested fix of cutting audio to the video length as the Wan2.2 S2V path does. The whole-PR diff (merge base 0f8a467 to head cc6b565) changes only src/pipeline/video.cpp. The existing S2V truncation block now also runs when sd_version_is_minimax_h3(sd->version) is true and generated_audio is non-null. It computes want_samples = video_frames / fps * sample_rate from the decoded frame count and request.fps, and shortens the audio only through the existing guard. For the issue example (124 frames, 24 fps, 32 kHz), this gives 165333 samples instead of 165600. The PR reports ffprobe and ffmpeg checks of an actual AVI confirming this. The change meets the coding requirement. Audio generation and the decoder are unchanged, as the issue does not request. Minor note: the code truncates with a floor cast, while the issue suggests round(); for the reported case both give 165333. The PR reports a 13-check model-free regression covering H3 at 24 fps, S2V at 16 fps, shorter audio, and no audio, but that test is not in the diff and was not re-run here.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR diff touches only one code block in src/pipeline/video.cpp. It extends the existing audio truncation condition to MiniMax-H3, renames the comment to general output-audio wording, and changes the LOG_DEBUG label from 's2v audio truncate' to 'output audio truncate'. Each change directly supports objective #2331. No unrelated files or behavior changes appear in the diff. The S2V behavior is preserved, since S2V still uses the same computation.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning Some tools did not complete. Review the errors below.
Cppcheck (2.22.0)
-
src/pipeline/video.cpp
-
Cppcheck timed out; analysis of this file is 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
-
Recent review info
-
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
9d0fcf9b-1dd6-4017-b6c9-31dbb2367496
Commits
-
Reviewing files that changed from the base of the PR and between 0f8a467 and cc6b565.
Files selected for processing: 1
-
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|