fix: preview source audio stops around 20s due to unreliable reported duration#722
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a new ChangesPreview audio duration resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant useAudioPreviewSync
participant resolvePreviewMediaDuration
participant AudioElement
useAudioPreviewSync->>AudioElement: read audio.duration
useAudioPreviewSync->>resolvePreviewMediaDuration: resolvePreviewMediaDuration(audio.duration, duration)
resolvePreviewMediaDuration-->>useAudioPreviewSync: sanitized audioDuration or null
useAudioPreviewSync->>useAudioPreviewSync: compute targetTime and atEnd
Related issues: Suggested labels: bug, audio, video-editor Suggested reviewers: webadderallorg maintainers 🐰 A rabbit hums a steady tune, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ExtraBinoss
left a comment
There was a problem hiding this comment.
Very good. No issues on my side, merging it since this is a lingering bug that affects lots of people.
|
That's fantastic—we're one step closer to a mature product! |
Pull Request Template
Description
Preview playback no longer cuts the source audio off around the 20-second mark. The audio-preview sync now treats an implausibly short reported media duration as unknown rather than trusting it, so audio keeps syncing for the real length of the clip.
Motivation
Issue #642 reports that in the video-editor preview the source audio stops at roughly 20 seconds even though the clip is longer. Early in playback the media element can report an implausibly short
duration; the audio-preview sync trusted that value and stopped driving audio past it. This adds amediaTiminghelper that rejects implausibly short/invalid durations (treating them as unknown), anduseAudioPreviewSyncuses it so a bogus early duration no longer truncates audio; when a valid duration is later reported, normal syncing continues.Type of Change
Related Issue(s)
Fixes #642
Screenshots / Video
N/A — this is a timing/logic fix in the preview audio sync path with no UI change. Behavior is covered by unit tests rather than a visual capture.
Testing Guide
Run the unit tests:
mediaTiming.test.tspasses, covering a valid duration being accepted, an implausibly short/zero/NaN duration treated as unknown, and a later valid duration being honored. To verify manually, open a clip longer than ~20s in the preview and confirm source audio continues past 20s.Checklist
Thank you for contributing!
Summary by CodeRabbit
New Features
Bug Fixes