Skip to content

Fix Symphonia total_duration for video containers#906

Open
Arjentix wants to merge 1 commit into
RustAudio:masterfrom
Arjentix:fix/symphonia-duration-wrong-track
Open

Fix Symphonia total_duration for video containers#906
Arjentix wants to merge 1 commit into
RustAudio:masterfrom
Arjentix:fix/symphonia-duration-wrong-track

Conversation

@Arjentix

Copy link
Copy Markdown

Hello!

I was using rodio 0.22.2 in my personal project and found two bugs. One of them is already fixed on master, 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::init derived total_duration by pairing the selected audio track's time_base with the default track's n_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). New tests/video_container_test.rs asserts 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).

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.

1 participant