Skip to content

Default audio bitrate comes from the last audio track instead of the first #128

Closed

Description

@zfleeman

When a video has more than one audio track, ff4d reads its default audio bitrate from the last track, not the first.

TwoPass._parse_streams() (twopass.py:340-342) sets audio_stream = stream["index"] for every audio stream it finds, so after the loop it holds the last one. Its docstring and the source_audio_br attribute docs both say it's the first track.

This matters for ShadowPlay and OBS clips, which often have game audio on track 0 and a microphone on track 1. The mic track usually has a lower bitrate, so ff4d picks a lower default audio bitrate than the game audio deserves.

The fix: _parse_streams() already collects every audio stream in self.audio_streams, in order. Read the bitrate from self.audio_streams[0] and remove the returned index and the self.probe["streams"][audio_stream] lookup. Add a test with two audio tracks that have different bitrates.

Fix this together with #127 (the MKV bit_rate crash), since both are in the same few lines.

Activity

  1. zfleeman commented on Oct 22, 2026

    @zfleeman
    OwnerAuthor

    Fixed in #130.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions