Repository navigation
Fix frame size/length leaking between streams of multi-stream files - #38
Merged
Merged
Conversation
create_ffaudiofileformats() declared frame_size and frame_length outside the per-stream loop and only set them conditionally (frame_size only for PCM, frame_length only if nb_frames or a usable duration and frame size are available). A compressed stream following a PCM stream therefore reported the PCM stream's frame size and frame length. Reset both at the start of each iteration and add a PCM + Vorbis Matroska test file covering the case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hendriks73
force-pushed
the
hendrik/multistream-frame-fields
branch
from
October 22, 2026 09:45
6006a88 to
d92bb47
Compare
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.
Problem
In
create_ffaudiofileformats()(FFAudioFileReader.c),frame_sizeandframe_lengthare declared outside the per-stream loop and are only set conditionally:frame_sizeis set only for PCM streams.frame_lengthis set only ifnb_frames, or a usable duration plus sample rate (and for compressed codecs, a fixed codec frame size), is available.So in a multi-stream file, a compressed stream that follows a PCM stream reports the PCM stream's frame size and frame length. All other per-stream values are already reassigned on every iteration.
Fix
Reset
frame_sizeandframe_lengthto-1(NOT_SPECIFIED) at the start of each stream iteration.Test
test_pcm_vorbis.mkv(93 KB): stream 0 is PCM S16LE stereo 44.1 kHz, stream 1 is Vorbis mono 22.05 kHz, 0.5 s each. Matroska sets nonb_frames, and Vorbis has no fixed codec frame size, so neither value gets set for stream 1. It was generated with:ffmpeg -f lavfi -i "sine=frequency=440:sample_rate=44100:duration=0.5" -f lavfi -i "sine=frequency=880:sample_rate=22050:duration=0.5" -filter_complex "[0:a]aformat=channel_layouts=stereo[a0]" -map "[a0]" -map 1:a -c:a:0 pcm_s16le -c:a:1 libvorbis -q:a:1 0 -fflags +bitexact -map_metadata -1 test_pcm_vorbis.mkvTestFFAudioFileReader#testGetAudioFileFormatsPcmThenVorbisMKVFile. Before the fix it failed withexpected:<-1> but was:<4>(Vorbis frame size inherited from the PCM stream). It passes after the fix.🤖 Generated with Claude Code