Fix Symphonia total_duration for video containers#906
Open
Arjentix wants to merge 1 commit into
Open
Conversation
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.
Hello!
I was using
rodio 0.22.2in my personal project and found two bugs. One of them is already fixed onmaster, but the other one is not, so here is my fix with an appropriate test.I must note that this was implemented by Claude.
Here goes more detailed description.
Problem
SymphoniaDecoder::initderivedtotal_durationby pairing the selected audio track'stime_basewith the default track'sn_frames.For a video file the default track is the video track, so its frame count paired with the audio track's time base yields a nonsense duration.
Fix
Compute the duration from the selected audio track's own
n_frames.default_track()is kept only as the pre-existing "no streams" guard.Impact
Audio-only files are unchanged (their default track already is the decoded track). Video containers now report the audio track's real length.
Test
Added
assets/video_with_audio.mp4— a synthetic 24 KB, 2 s clip (H.264 video as the default track + 2 s mono AAC). Newtests/video_container_test.rsasserts the decoder reports the audio track's duration (~2.02 s), not the video-derived value. Measured before/after on this fixture: 0.70 s (buggy) → 2.02 s (fixed).